Fix golangci-lint issues

This commit is contained in:
Ben Johnson
2022-01-31 08:54:02 -07:00
parent e84994ad95
commit 5d811f2e39
9 changed files with 47 additions and 112 deletions

View File

@@ -1,6 +1,7 @@
package internal
import (
"crypto/md5"
"fmt"
"io"
"math"
@@ -180,7 +181,7 @@ func ParseWALSegmentPath(s string) (index int, offset int64, err error) {
if i32 > math.MaxInt32 {
return 0, 0, fmt.Errorf("index too large in wal segment path %q", s)
}
off64, _ := strconv.ParseInt(a[2], 16, 64)
off64, _ := strconv.ParseUint(a[2], 16, 64)
if off64 > math.MaxInt64 {
return 0, 0, fmt.Errorf("offset too large in wal segment path %q", s)
}
@@ -228,3 +229,8 @@ func TruncateDuration(d time.Duration) time.Duration {
}
return d
}
// MD5hash returns a hex-encoded MD5 hash of b.
func MD5hash(b []byte) string {
return fmt.Sprintf("%x", md5.Sum(b))
}