From a418abc7d5ccfc806318caa9effa99d9f955fbcb Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Fri, 27 Feb 2026 14:40:26 +0100 Subject: [PATCH] Run go fix --- internal/api/rest.go | 2 +- pkg/archive/fsBackend.go | 6 ++---- pkg/archive/s3Backend.go | 6 ++---- pkg/archive/sqliteBackend.go | 6 ++---- pkg/metricstore/archive.go | 6 ++---- pkg/metricstore/checkpoint.go | 6 ++---- pkg/metricstore/metricstore.go | 12 ++++-------- pkg/metricstore/walCheckpoint.go | 14 +++++++------- 8 files changed, 22 insertions(+), 36 deletions(-) diff --git a/internal/api/rest.go b/internal/api/rest.go index 4d2385e3..613867a8 100644 --- a/internal/api/rest.go +++ b/internal/api/rest.go @@ -302,7 +302,7 @@ func (api *RestAPI) runTagger(rw http.ResponseWriter, r *http.Request) { rw.Header().Set("Content-Type", "text/plain") rw.WriteHeader(http.StatusOK) - if _, err := rw.Write([]byte(fmt.Sprintf("Tagger %s started", name))); err != nil { + if _, err := rw.Write(fmt.Appendf(nil, "Tagger %s started", name)); err != nil { cclog.Errorf("Failed to write response: %v", err) } } diff --git a/pkg/archive/fsBackend.go b/pkg/archive/fsBackend.go index 07b86e2b..dfc870b4 100644 --- a/pkg/archive/fsBackend.go +++ b/pkg/archive/fsBackend.go @@ -501,9 +501,7 @@ func (fsa *FsArchive) Iter(loadMetricData bool) <-chan JobContainer { var wg sync.WaitGroup for range numWorkers { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for jobPath := range jobPaths { job, err := loadJobMeta(filepath.Join(jobPath, "meta.json")) if err != nil && !errors.Is(err, &jsonschema.ValidationError{}) { @@ -529,7 +527,7 @@ func (fsa *FsArchive) Iter(loadMetricData bool) <-chan JobContainer { ch <- JobContainer{Meta: job, Data: nil} } } - }() + }) } clustersDir, err := os.ReadDir(fsa.path) diff --git a/pkg/archive/s3Backend.go b/pkg/archive/s3Backend.go index 84abd713..7b82d309 100644 --- a/pkg/archive/s3Backend.go +++ b/pkg/archive/s3Backend.go @@ -821,9 +821,7 @@ func (s3a *S3Archive) Iter(loadMetricData bool) <-chan JobContainer { var wg sync.WaitGroup for range numWorkers { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for metaKey := range metaKeys { result, err := s3a.client.GetObject(ctx, &s3.GetObjectInput{ Bucket: aws.String(s3a.bucket), @@ -859,7 +857,7 @@ func (s3a *S3Archive) Iter(loadMetricData bool) <-chan JobContainer { ch <- JobContainer{Meta: job, Data: nil} } } - }() + }) } for _, cluster := range s3a.clusters { diff --git a/pkg/archive/sqliteBackend.go b/pkg/archive/sqliteBackend.go index 50821367..3f214136 100644 --- a/pkg/archive/sqliteBackend.go +++ b/pkg/archive/sqliteBackend.go @@ -576,9 +576,7 @@ func (sa *SqliteArchive) Iter(loadMetricData bool) <-chan JobContainer { var wg sync.WaitGroup for range numWorkers { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { for row := range jobRows { job, err := DecodeJobMeta(bytes.NewReader(row.metaBlob)) if err != nil { @@ -617,7 +615,7 @@ func (sa *SqliteArchive) Iter(loadMetricData bool) <-chan JobContainer { ch <- JobContainer{Meta: job, Data: nil} } } - }() + }) } for { diff --git a/pkg/metricstore/archive.go b/pkg/metricstore/archive.go index 784348b5..d3617f2c 100644 --- a/pkg/metricstore/archive.go +++ b/pkg/metricstore/archive.go @@ -49,9 +49,7 @@ func CleanUp(wg *sync.WaitGroup, ctx context.Context) { // runWorker takes simple values to configure what it does func cleanUpWorker(wg *sync.WaitGroup, ctx context.Context, interval string, mode string, cleanupDir string, delete bool) { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { d, err := time.ParseDuration(interval) if err != nil { @@ -85,7 +83,7 @@ func cleanUpWorker(wg *sync.WaitGroup, ctx context.Context, interval string, mod } } } - }() + }) } var ErrNoNewArchiveData error = errors.New("all data already archived") diff --git a/pkg/metricstore/checkpoint.go b/pkg/metricstore/checkpoint.go index 590197e3..45b2bc2a 100644 --- a/pkg/metricstore/checkpoint.go +++ b/pkg/metricstore/checkpoint.go @@ -96,9 +96,7 @@ func Checkpointing(wg *sync.WaitGroup, ctx context.Context) { ms := GetMemoryStore() - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { d, err := time.ParseDuration(Keys.Checkpoints.Interval) if err != nil { @@ -149,7 +147,7 @@ func Checkpointing(wg *sync.WaitGroup, ctx context.Context) { } } } - }() + }) } // MarshalJSON provides optimized JSON encoding for CheckpointMetrics. diff --git a/pkg/metricstore/metricstore.go b/pkg/metricstore/metricstore.go index 3fe64d55..d46c0d15 100644 --- a/pkg/metricstore/metricstore.go +++ b/pkg/metricstore/metricstore.go @@ -320,9 +320,7 @@ func Shutdown() { func Retention(wg *sync.WaitGroup, ctx context.Context) { ms := GetMemoryStore() - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { d, err := time.ParseDuration(Keys.RetentionInMemory) if err != nil { cclog.Fatal(err) @@ -361,7 +359,7 @@ func Retention(wg *sync.WaitGroup, ctx context.Context) { state.mu.Unlock() } } - }() + }) } // MemoryUsageTracker starts a background goroutine that monitors memory usage. @@ -382,9 +380,7 @@ func Retention(wg *sync.WaitGroup, ctx context.Context) { func MemoryUsageTracker(wg *sync.WaitGroup, ctx context.Context) { ms := GetMemoryStore() - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { d := DefaultMemoryUsageTrackerInterval if d <= 0 { @@ -470,7 +466,7 @@ func MemoryUsageTracker(wg *sync.WaitGroup, ctx context.Context) { } } } - }() + }) } // Free removes metric data older than the given time while preserving data for active nodes. diff --git a/pkg/metricstore/walCheckpoint.go b/pkg/metricstore/walCheckpoint.go index e8a71ce2..685a8388 100644 --- a/pkg/metricstore/walCheckpoint.go +++ b/pkg/metricstore/walCheckpoint.go @@ -65,6 +65,7 @@ import ( "math" "os" "path" + "strings" "sync" "sync/atomic" @@ -114,9 +115,7 @@ type walFileState struct { // and appends binary WAL records to per-host current.wal files. // Also handles WAL rotation requests from the checkpoint goroutine. func WALStaging(wg *sync.WaitGroup, ctx context.Context) { - wg.Add(1) - go func() { - defer wg.Done() + wg.Go(func() { if Keys.Checkpoints.FileFormat == "json" { return @@ -220,7 +219,7 @@ func WALStaging(wg *sync.WaitGroup, ctx context.Context) { processRotate(req) } } - }() + }) } // RotateWALFiles sends rotation requests for the given host directories @@ -478,11 +477,12 @@ func joinSelector(sel []string) string { if len(sel) == 0 { return "" } - result := sel[0] + var result strings.Builder + result.WriteString(sel[0]) for i := 1; i < len(sel); i++ { - result += "\x00" + sel[i] + result.WriteString("\x00" + sel[i]) } - return result + return result.String() } // ToCheckpointWAL writes binary snapshot files for all hosts in parallel.