From e281b58165f521765c9d578c1c8f73a68b2c146f Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 8 Mar 2024 20:15:18 +0100 Subject: [PATCH] Bump Go versions (#303) --- .github/workflows/go.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/vulncheck.yml | 2 +- api/api.go | 2 +- cli/benchclient.go | 2 +- cli/cli.go | 2 +- cli/influx.go | 4 ++-- pkg/bench/mixed.go | 4 ++-- pkg/bench/versioned.go | 9 ++++----- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6cedbaa9..cc041843 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go-version: [1.20.x, 1.21.x] + go-version: [1.21.x, 1.22.x] os: [ubuntu-latest, macos-latest, windows-latest] steps: - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} @@ -37,7 +37,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.21.x + go-version: 1.22.x - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a59ff5a2..26a4193a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.21.x + go-version: 1.22.x - name: Run GoReleaser uses: goreleaser/goreleaser-action@53acad1befee355d46f71cccf6ab4d885eb4f77f diff --git a/.github/workflows/vulncheck.yml b/.github/workflows/vulncheck.yml index 4c8ee2b0..ea7d3086 100644 --- a/.github/workflows/vulncheck.yml +++ b/.github/workflows/vulncheck.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [ 1.21.5 ] + go-version: [ 1.22.x ] steps: - name: Check out code into the Go module directory uses: actions/checkout@v3 diff --git a/api/api.go b/api/api.go index 906a853f..f0edbe3c 100644 --- a/api/api.go +++ b/api/api.go @@ -167,7 +167,7 @@ func (s *Server) handleAggregated(w http.ResponseWriter, req *http.Request) { w.Write([]byte(err.Error())) return } - durFn := func(total time.Duration) time.Duration { + durFn := func(time.Duration) time.Duration { return segmentDur } s.mu.Lock() diff --git a/cli/benchclient.go b/cli/benchclient.go index ae8a1a1e..80ef0a7d 100644 --- a/cli/benchclient.go +++ b/cli/benchclient.go @@ -108,7 +108,7 @@ var ( // wsUpgrader performs websocket upgrades. var wsUpgrader = websocket.Upgrader{ - CheckOrigin: func(r *http.Request) bool { + CheckOrigin: func(_ *http.Request) bool { return true }, } diff --git a/cli/cli.go b/cli/cli.go index 99275f9e..4c34c889 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -193,7 +193,7 @@ func registerApp(name string, appCmds []cli.Command) *cli.App { return nil } - afterExec = func(ctx *cli.Context) error { + afterExec = func(_ *cli.Context) error { for _, profile := range profiles { profile.Stop() } diff --git a/cli/influx.go b/cli/influx.go index 59eaa4b0..96dce4df 100644 --- a/cli/influx.go +++ b/cli/influx.go @@ -70,8 +70,8 @@ func newInfluxDB(ctx *cli.Context, wg *sync.WaitGroup) chan<- bench.Operation { // Use blocking write client for writes to desired bucket path := strings.Split(strings.TrimPrefix(u.Path, "/"), "/") writeAPI := client.WriteAPI(path[1], path[0]) - writeAPI.SetWriteFailedCallback(func(batch string, error http.Error, retryAttempts uint) bool { - errorIf(probe.NewError(err), "unable to write to influxdb") + writeAPI.SetWriteFailedCallback(func(_ string, err http.Error, _ uint) bool { + errorIf(probe.NewError(&err), "unable to write to influxdb") return false }) ch := make(chan bench.Operation, 10000) diff --git a/pkg/bench/mixed.go b/pkg/bench/mixed.go index 1d69ce84..1209adb9 100644 --- a/pkg/bench/mixed.go +++ b/pkg/bench/mixed.go @@ -170,7 +170,7 @@ func (g *Mixed) Prepare(ctx context.Context) error { var groupErr error var mu sync.Mutex for i := 0; i < g.Concurrency; i++ { - go func(i int) { + go func() { defer wg.Done() src := g.Source() @@ -218,7 +218,7 @@ func (g *Mixed) Prepare(ctx context.Context) error { g.Dist.addObj(*obj) g.prepareProgress(float64(len(g.Dist.objects)) / float64(g.CreateObjects)) } - }(i) + }() } wg.Wait() return groupErr diff --git a/pkg/bench/versioned.go b/pkg/bench/versioned.go index 10e460cc..511b5b07 100644 --- a/pkg/bench/versioned.go +++ b/pkg/bench/versioned.go @@ -24,7 +24,6 @@ import ( "io" "math/rand" "net/http" - "sort" "sync" "time" @@ -75,7 +74,7 @@ func (g *Versioned) Prepare(ctx context.Context) error { var groupErr error var mu sync.Mutex for i := 0; i < g.Concurrency; i++ { - go func(i int) { + go func() { defer wg.Done() src := g.Source() @@ -123,7 +122,7 @@ func (g *Versioned) Prepare(ctx context.Context) error { g.Dist.addObj(*obj) g.prepareProgress(float64(len(g.Dist.objects)) / float64(g.CreateObjects)) } - }(i) + }() } wg.Wait() return groupErr @@ -339,8 +338,8 @@ func (m *VersionedDistribution) Generate(allocObjs int) error { } } m.rng = rand.New(rand.NewSource(0xabad1dea)) - sort.Slice(m.ops, func(i, j int) bool { - return m.rng.Int63()&1 == 0 + m.rng.Shuffle(len(m.ops), func(i, j int) { + m.ops[i], m.ops[j] = m.ops[j], m.ops[i] }) return nil }