Browse Source

src/internal/bytealg: fix indexing error in Compare()

Fixes #2139
pull/2142/head
Damian Gryski 3 years ago
committed by Ron Evans
parent
commit
25011c5078
  1. 4
      src/internal/bytealg/bytealg.go

4
src/internal/bytealg/bytealg.go

@ -15,9 +15,9 @@ func Compare(a, b []byte) int {
// Compare for differing bytes. // Compare for differing bytes.
for i := 0; i < len(a) && i < len(b); i++ { for i := 0; i < len(a) && i < len(b); i++ {
switch { switch {
case a[0] < b[0]: case a[i] < b[i]:
return -1 return -1
case a[0] > b[0]: case a[i] > b[i]:
return 1 return 1
} }
} }

Loading…
Cancel
Save