Skip to content

Commit

Permalink
chore(build): Update required Go version to 1.23.4 (#33)
Browse files Browse the repository at this point in the history
* build: upgrade go version to 1.23.4

* chore(lint): update linter and fix new reports
  • Loading branch information
dwelch-spike authored Jan 16, 2025
1 parent 4592c84 commit e727cf3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- name: Setup-go
uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.23
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.58
version: v1.61
args: --timeout=5m --out-format=colored-line-number
23 changes: 20 additions & 3 deletions cmd/flags/optionals.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package flags
import (
"asvec/utils"
"fmt"
"math"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -184,7 +185,13 @@ func (f *DurationOptionalFlag) Uint64() *uint64 {
return nil
}

milli := uint64(f.Val.Milliseconds())
mili := f.Val.Milliseconds()

if mili < 0 {
panic("duration is negative, cannot convert to uint64")
}

milli := uint64(mili)

return &milli
}
Expand All @@ -194,9 +201,19 @@ func (f *DurationOptionalFlag) Uint32() *uint32 {
return nil
}

milli := uint32(f.Val.Milliseconds())
milli := f.Val.Milliseconds()

return &milli
if milli < 0 {
panic("duration is negative, cannot convert to uint32")
}

if milli > math.MaxUint32 {
panic("duration is too large, cannot convert to uint32")
}

res := uint32(milli)

return &res
}

func (f *DurationOptionalFlag) Int64() *int64 {
Expand Down
5 changes: 5 additions & 0 deletions cmd/flags/unixtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flags

import (
"fmt"
"math"
"strconv"
"time"
)
Expand All @@ -14,6 +15,10 @@ func (f *UnixTimestampFlag) Set(val string) error {
return fmt.Errorf("invalid timestamp: %w", err)
}

if timestamp > math.MaxInt64 {
return fmt.Errorf("timestamp is larger than the maximum 64 bit integer")
}

*f = UnixTimestampFlag(time.Unix(int64(timestamp), 0))

return nil
Expand Down
18 changes: 18 additions & 0 deletions cmd/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log/slog"
"math"
"reflect"

"github.com/aerospike/avs-client-go"
Expand Down Expand Up @@ -185,6 +186,23 @@ asvec query -i my-index -n my-namespace -v "[1,0,1,0,0,0,1,0,1,1]" --max-keys 10
queryFlags.maxDataKeys = 0
}

if queryFlags.maxDataKeys > math.MaxInt {
err := fmt.Errorf("maxDataKeys value is larger than the maximum integer: %d", queryFlags.maxDataKeys)
logger.ErrorContext(ctx, "unable to convert maxDataKeys to int", slog.Any("error", err))
view.Errorf("Failed to get index definition: %s", err)

return
}

if queryFlags.maxDataColWidth > math.MaxInt {
err := fmt.Errorf("maxDataColWidth value is larger than the maximum integer: %d", queryFlags.maxDataColWidth)
logger.ErrorContext(ctx, "unable to convert maxDataColWidth to int", slog.Any("error", err))
view.Errorf("Failed to get index definition: %s", err)

return
}

//nolint:gosec // Overflow is checked above
view.PrintQueryResults(neighbors, queryFlags.format, int(queryFlags.maxDataKeys), int(queryFlags.maxDataColWidth))

if !viper.IsSet(flags.MaxResults) {
Expand Down
3 changes: 3 additions & 0 deletions cmd/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ func (v *View) Warning(f string) {

func (v *View) Warningf(f string, a ...any) {
errCode.Store(1)
//nolint:govet // these need to be dynamic
v.PrintfErr(v.yellowString("Warning: "+f, a...))
}

func (v *View) Error(f string) {
errCode.Store(1)
//nolint:govet // these need to be dynamic
v.PrintfErr(v.redString("Error: %s", f))
}

func (v *View) Errorf(f string, a ...any) {
errCode.Store(1)
//nolint:govet // these need to be dynamic
v.PrintfErr(v.redString("Error: "+f, a...))
}

Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module asvec

go 1.22.0

toolchain go1.22.1
go 1.23.4

require (
github.com/aerospike/avs-client-go v0.0.0-20241231190028-5ae966997032
Expand Down

0 comments on commit e727cf3

Please sign in to comment.