Skip to content

Commit

Permalink
Merge pull request #27 from martinlindhe/master
Browse files Browse the repository at this point in the history
fix some typos and trivial 'go vet'
  • Loading branch information
bormanp authored Nov 22, 2017
2 parents 8c31c18 + 9c6b413 commit 4ebdd04
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID {
h.Reset()
h.Write(space[:])
h.Write([]byte(data))
h.Write(data)
s := h.Sum(nil)
var uuid UUID
copy(uuid[:], s)
Expand Down
2 changes: 1 addition & 1 deletion seq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var regressions = flag.Bool("regressions", false, "run uuid regression tests")

// TestClockSeqRace tests for a particular race condition of returning two
// identical Version1 UUIDs. The duration of 1 minute was chosen as the race
// condition, before being fixed, nearly always occured in under 30 seconds.
// condition, before being fixed, nearly always occurred in under 30 seconds.
func TestClockSeqRace(t *testing.T) {
if !*regressions {
t.Skip("skipping regression tests")
Expand Down
6 changes: 3 additions & 3 deletions sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
)

func TestScan(t *testing.T) {
var stringTest string = "f47ac10b-58cc-0372-8567-0e02b2c3d479"
var badTypeTest int = 6
var invalidTest string = "f47ac10b-58cc-0372-8567-0e02b2c3d4"
stringTest := "f47ac10b-58cc-0372-8567-0e02b2c3d479"
badTypeTest := 6
invalidTest := "f47ac10b-58cc-0372-8567-0e02b2c3d4"

byteTest := make([]byte, 16)
byteTestUUID := Must(Parse(stringTest))
Expand Down
6 changes: 3 additions & 3 deletions time.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func clockSequence() int {
return int(clockSeq & 0x3fff)
}

// SetClockSeq sets the clock sequence to the lower 14 bits of seq. Setting to
// SetClockSequence sets the clock sequence to the lower 14 bits of seq. Setting to
// -1 causes a new sequence to be generated.
func SetClockSequence(seq int) {
defer timeMu.Unlock()
Expand All @@ -100,9 +100,9 @@ func setClockSequence(seq int) {
randomBits(b[:]) // clock sequence
seq = int(b[0])<<8 | int(b[1])
}
old_seq := clockSeq
oldSeq := clockSeq
clockSeq = uint16(seq&0x3fff) | 0x8000 // Set our variant
if old_seq != clockSeq {
if oldSeq != clockSeq {
lasttime = 0
}
}
Expand Down
12 changes: 6 additions & 6 deletions uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func Parse(s string) (UUID, error) {
14, 16,
19, 21,
24, 26, 28, 30, 32, 34} {
if v, ok := xtob(s[x], s[x+1]); !ok {
v, ok := xtob(s[x], s[x+1])
if !ok {
return uuid, errors.New("invalid UUID format")
} else {
uuid[i] = v
}
uuid[i] = v
}
return uuid, nil
}
Expand All @@ -88,11 +88,11 @@ func ParseBytes(b []byte) (UUID, error) {
14, 16,
19, 21,
24, 26, 28, 30, 32, 34} {
if v, ok := xtob(b[x], b[x+1]); !ok {
v, ok := xtob(b[x], b[x+1])
if !ok {
return uuid, errors.New("invalid UUID format")
} else {
uuid[i] = v
}
uuid[i] = v
}
return uuid, nil
}
Expand Down
12 changes: 6 additions & 6 deletions uuid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestVersion1(t *testing.T) {
case t1 > t2 && q1 == q2:
t.Error("time reversed")
case t1 < t2 && q1 != q2:
t.Error("clock sequence chaned unexpectedly")
t.Error("clock sequence changed unexpectedly")
}
}

Expand Down Expand Up @@ -347,7 +347,7 @@ func TestNode(t *testing.T) {
}

if ni := NodeInterface(); ni != "user" {
t.Errorf("got inteface %q, want %q", ni, "user")
t.Errorf("got interface %q, want %q", ni, "user")
}
}

Expand Down Expand Up @@ -392,7 +392,7 @@ func TestNodeID(t *testing.T) {
SetNodeInterface("")
s := NodeInterface()
if s == "" || s == "user" {
t.Errorf("NodeInterface %q after SetInteface", s)
t.Errorf("NodeInterface %q after SetInterface", s)
}
node1 := NodeID()
if node1 == nil {
Expand Down Expand Up @@ -443,7 +443,7 @@ func TestDCE(t *testing.T) {
type badRand struct{}

func (r badRand) Read(buf []byte) (int, error) {
for i, _ := range buf {
for i := range buf {
buf[i] = byte(i)
}
return len(buf), nil
Expand All @@ -454,13 +454,13 @@ func TestBadRand(t *testing.T) {
uuid1 := New()
uuid2 := New()
if uuid1 != uuid2 {
t.Errorf("execpted duplicates, got %q and %q", uuid1, uuid2)
t.Errorf("expected duplicates, got %q and %q", uuid1, uuid2)
}
SetRand(nil)
uuid1 = New()
uuid2 = New()
if uuid1 == uuid2 {
t.Errorf("unexecpted duplicates, got %q", uuid1)
t.Errorf("unexpected duplicates, got %q", uuid1)
}
}

Expand Down
2 changes: 1 addition & 1 deletion version4.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func New() UUID {
return Must(NewRandom())
}

// NewRandom returns a Random (Version 4) UUID or panics.
// NewRandom returns a Random (Version 4) UUID.
//
// The strength of the UUIDs is based on the strength of the crypto/rand
// package.
Expand Down

0 comments on commit 4ebdd04

Please sign in to comment.