Skip to content

Commit

Permalink
fix gomnd issues
Browse files Browse the repository at this point in the history
  • Loading branch information
11Petrov committed Feb 22, 2024
1 parent d134a39 commit b532c43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/cmd/gtrace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
)

const (
noTags = 0
oneTag = 1
twoTags = 2
)

//go:linkname build_goodOSArchFile go/build.(*Context).goodOSArchFile
//nolint:revive
func build_goodOSArchFile(*build.Context, string, map[string]bool) bool
Expand Down Expand Up @@ -318,17 +324,16 @@ func splitOSArchTags(ctx *build.Context, name string) (base, tags, ext string) {
build_goodOSArchFile(ctx, name, fileTags)
ext = filepath.Ext(name)
switch len(fileTags) {
case 0: // *
case noTags: // *
base = strings.TrimSuffix(name, ext)

case 1: // *_GOOS or *_GOARCH
case oneTag: // *_GOOS or *_GOARCH
i := strings.LastIndexByte(name, '_')

base = name[:i]
tags = strings.TrimSuffix(name[i:], ext)

//nolint:gomnd
case 2: // *_GOOS_GOARCH
case twoTags: // *_GOOS_GOARCH
var i int
i = strings.LastIndexByte(name, '_')
i = strings.LastIndexByte(name[:i], '_')
Expand Down
1 change: 1 addition & 0 deletions internal/value/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func DatetimeToTime(n uint32) time.Time {
func TimestampToTime(n uint64) time.Time {
sec := n / microsecondsPerSecond
nsec := (n - (sec * microsecondsPerSecond)) * nanosecondsPerMicrosecond

return time.Unix(int64(sec), int64(nsec))
}

Expand Down

0 comments on commit b532c43

Please sign in to comment.