From 1391f44ebea8f7937f097c3a93361e3bf009bda6 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 8 Mar 2024 13:05:03 +0100 Subject: [PATCH] Fix linter errors --- 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 ++++----- 6 files changed, 11 insertions(+), 12 deletions(-) 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 }