Skip to content

Commit

Permalink
Removed the unused err reporting from NewUUID()
Browse files Browse the repository at this point in the history
  • Loading branch information
deiu committed Jul 21, 2015
1 parent c613e26 commit d43c97b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
10 changes: 4 additions & 6 deletions ldp.go
Expand Up @@ -137,15 +137,13 @@ func (l *Linkheaders) MatchURI(uri string) bool {
return false
}

func newUUID() (string, error) {
// NewUUID generates a new UUID string
func NewUUID() string {
uuid := make([]byte, 16)
n, err := io.ReadFull(rand.Reader, uuid)
if n != len(uuid) || err != nil {
return "", err
}
io.ReadFull(rand.Reader, uuid)
uuid[8] = uuid[8]&^0xc0 | 0x80
uuid[6] = uuid[6]&^0xf0 | 0x40
return hex.EncodeToString(uuid), nil
return hex.EncodeToString(uuid)
}

// NewETag generates ETag
Expand Down
17 changes: 1 addition & 16 deletions ldp_test.go
@@ -1,7 +1,6 @@
package gold

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -48,20 +47,6 @@ func TestPreferHeaderParser(t *testing.T) {
}

func TestNewUUID(t *testing.T) {
uuid, err := newUUID()
assert.Nil(t, err)
uuid := NewUUID()
assert.Equal(t, 32, len(uuid))
}

func BenchmarkNewUUID(b *testing.B) {
e := 0
for i := 0; i < b.N; i++ {
if _, err := newUUID(); err != nil {
e++
}
}
if e > 0 {
b.Log(fmt.Sprintf("%d/%d failed", e, b.N))
b.Fail()
}
}
2 changes: 1 addition & 1 deletion server.go
Expand Up @@ -790,7 +790,7 @@ func (s *Server) handle(w http.ResponseWriter, req *httpRequest) (r *response) {
link := ParseLinkHeader(req.Header.Get("Link")).MatchRel("type")
slug := req.Header.Get("Slug")

uuid, err := newUUID()
uuid := NewUUID()
if err != nil {
s.debug.Println("POST LDP UUID err: " + err.Error())
return r.respond(500, err)
Expand Down

0 comments on commit d43c97b

Please sign in to comment.