Skip to content

Apply go fix ./...#8074

Merged
yurishkuro merged 7 commits into
jaegertracing:mainfrom
yurishkuro:go-fix
Feb 20, 2026
Merged

Apply go fix ./...#8074
yurishkuro merged 7 commits into
jaegertracing:mainfrom
yurishkuro:go-fix

Conversation

@yurishkuro
Copy link
Copy Markdown
Member

@yurishkuro yurishkuro commented Feb 20, 2026

Apply go fix ./... modernizations with some manual clean-up afterwards.

Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Copilot AI review requested due to automatic review settings February 20, 2026 20:27
@yurishkuro yurishkuro requested a review from a team as a code owner February 20, 2026 20:27
@yurishkuro yurishkuro added the changelog:refactoring Internal code refactoring without functional changes label Feb 20, 2026
@dosubot dosubot Bot added area/sampling go Pull requests that update go code labels Feb 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request applies automated Go tooling fixes ("go fix") to modernize the codebase with Go 1.23+ features. However, the automated changes contain critical bugs that will prevent compilation, making this PR unsuitable for merging in its current state.

Changes:

  • Modernizes loop syntax using for range n instead of for i := 0; i < n; i++
  • Updates string manipulation to use strings.CutPrefix instead of HasPrefix + TrimPrefix
  • Adopts maps.Copy for map copying and reflect.TypeFor for type reflection
  • Uses sync.WaitGroup.Go() method for goroutine management
  • Attempts to replace pointer creation pattern &v with new(v) (this is incorrect)
  • Updates other patterns including import aliases and formatting functions

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
internal/storage/v2/memory/tenant.go Updates string prefix checking to use strings.CutPrefix
internal/storage/v2/memory/sampling_test.go Simplifies loop syntax to for range n
internal/storage/v2/elasticsearch/tracestore/writer.go Simplifies loop to for i range slice
internal/storage/v2/elasticsearch/tracestore/from_dbmodel_test.go Simplifies loop syntax
internal/storage/v2/clickhouse/tracestore/query_builder.go Simplifies loop for indentation
internal/storage/v2/cassandra/tracestore/from_dbmodel_test.go Simplifies loop syntax
internal/storage/v1/elasticsearch/spanstore/reader_test.go Simplifies loop syntax
internal/storage/v1/elasticsearch/options.go CRITICAL BUG: Incorrectly changes &v to new(v)
internal/storage/v1/elasticsearch/mappings/mapping_test.go CRITICAL BUG: Incorrectly uses new(value) instead of ptr(value)
internal/storage/v1/elasticsearch/mappings/command_test.go CRITICAL BUG: Incorrectly uses new(value) instead of ptr(value)
internal/storage/v1/elasticsearch/factory_test.go CRITICAL BUG: Incorrectly uses new(value) instead of ptr(value)
internal/storage/v1/badger/spanstore/rw_internal_test.go Simplifies loop syntax
internal/storage/v1/badger/spanstore/reader.go Simplifies loop syntax
internal/storage/v1/badger/spanstore/read_write_test.go Simplifies loop syntax
internal/storage/v1/badger/factory_test.go Simplifies loop syntax
internal/storage/v1/badger/dependencystore/storage_test.go Simplifies loop syntax
internal/storage/metricstore/elasticsearch/processor_test.go CRITICAL BUG: Incorrectly changes &d to new(d)
internal/storage/integration/integration.go Simplifies loop syntax
internal/storage/integration/elasticsearch_test.go Simplifies loop syntax
internal/storage/elasticsearch/dbmodel/model.go CRITICAL: Removes omitempty JSON tag (breaking change)
internal/storage/elasticsearch/config/config_test.go CRITICAL BUG: Incorrectly changes &v to new(v)
internal/storage/elasticsearch/config/config.go Updates map copying to use maps.Copy
internal/sampling/samplingstrategy/file/provider_test.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/weightvectorcache.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/provider_test.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/provider.go Uses WaitGroup.Go() method
internal/sampling/samplingstrategy/adaptive/post_aggregator_test.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/post_aggregator.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/aggregator_test.go Simplifies loop syntax
internal/sampling/samplingstrategy/adaptive/aggregator.go Uses WaitGroup.Go() method
internal/sampling/grpc/grpc_handler_test.go Renames context import to context0 (unconventional)
internal/metrics/metrics_test.go Simplifies loop syntax
internal/metrics/metrics.go Updates to use reflect.TypeFor
internal/leaderelection/leader_election_test.go Simplifies loop syntax
internal/gogocodec/codec_test.go Updates to use reflect.TypeFor and simplifies loop
internal/cache/lru_test.go Simplifies loop syntax
internal/auth/tokenloader_test.go Simplifies loop syntax
examples/hotrod/services/driver/server.go BUG: Variable shadowing in nested loops
examples/hotrod/pkg/pool/pool.go Simplifies loop syntax
cmd/remote-storage/app/server.go Uses WaitGroup.Go() method
cmd/jaeger/internal/extension/remotesampling/extension.go Uses WaitGroup.Go() method
cmd/jaeger/internal/extension/jaegerquery/internal/static_handler_test.go Simplifies loop syntax
cmd/jaeger/internal/extension/jaegerquery/internal/static_handler.go Changes fmt.Sprintf to fmt.Appendf
cmd/jaeger/internal/extension/jaegerquery/internal/server.go Uses WaitGroup.Go() method
cmd/jaeger/internal/extension/jaegerquery/internal/http_handler_test.go Simplifies loop syntax
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/get_span_names_test.go Simplifies loop syntax
cmd/jaeger/internal/extension/jaegermcp/internal/handlers/get_services_test.go Simplifies loop syntax
cmd/jaeger/internal/extension/jaegermcp/internal/criticalpath/sanitize_test.go Updates to use maps.Copy
cmd/jaeger/internal/extension/jaegermcp/internal/criticalpath/get_child_of_spans_test.go Updates to use maps.Copy
cmd/jaeger/internal/extension/expvar/extension.go Uses WaitGroup.Go() method
cmd/internal/storageconfig/config_test.go Updates to use reflect.TypeFor and Type.Fields()
cmd/internal/flags/service_test.go Simplifies loop syntax
cmd/es-rollover/app/init/flags.go CRITICAL BUG: Incorrectly changes &v to new(v)
cmd/es-rollover/app/init/action_test.go CRITICAL BUG: Incorrectly uses new(value)
cmd/anonymizer/app/writer/writer_test.go Simplifies loop syntax
cmd/anonymizer/app/query/query_test.go Uses WaitGroup.Go() method
cmd/anonymizer/app/anonymizer/anonymizer.go Uses WaitGroup.Go() method
Comments suppressed due to low confidence (1)

examples/hotrod/services/driver/server.go:78

  • The inner loop variable i shadows the outer loop variable i (from line 70). This creates a bug because line 78 uses i+1 expecting the retry counter, but i now refers to the inner loop variable which ranges from 0-2. The error log message will incorrectly show retry numbers 1, 2, 3 instead of the intended values. The inner loop should use a different variable name, such as retryCount or attempt.
		for i := range 3 {
			drv, err = s.redis.GetDriver(ctx, driverID)
			if err == nil {
				break
			}
			s.logger.For(ctx).Error("Retrying GetDriver after error", zap.Int("retry_no", i+1), zap.Error(err))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/storage/v1/elasticsearch/options.go
Comment thread internal/storage/v1/elasticsearch/mappings/mapping_test.go
Comment thread internal/storage/metricstore/elasticsearch/processor_test.go Outdated
Comment thread internal/storage/elasticsearch/dbmodel/model.go
Comment thread cmd/internal/storageconfig/config_test.go Outdated
Comment thread internal/storage/v1/elasticsearch/mappings/command_test.go
Comment thread cmd/es-rollover/app/init/flags.go Outdated
Comment thread cmd/es-rollover/app/init/flags.go Outdated
Comment thread cmd/es-rollover/app/init/action_test.go
Comment thread internal/storage/elasticsearch/config/config_test.go Outdated
Comment thread internal/storage/metricstore/elasticsearch/processor_test.go Outdated
Signed-off-by: Yuri Shkuro <github@ysh.us>
@yurishkuro yurishkuro changed the title Go fix Apply go fix ./... Feb 20, 2026
Signed-off-by: Yuri Shkuro <github@ysh.us>
Copilot AI review requested due to automatic review settings February 20, 2026 20:49
Signed-off-by: Yuri Shkuro <github@ysh.us>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 58 out of 58 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Yuri Shkuro <github@ysh.us>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Copilot AI review requested due to automatic review settings February 20, 2026 21:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 58 out of 58 changed files in this pull request and generated 18 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

EsVersion: 7,
Shards: 5,
Replicas: ptr(int64(1)),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(1)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
Comment on lines +744 to +754
Replicas: new(int64(1)),
Priority: 10,
},
Services: IndexOptions{
Shards: 5,
Replicas: int64Ptr(1),
Replicas: new(int64(1)),
Priority: 20,
},
Dependencies: IndexOptions{
Shards: 5,
Replicas: int64Ptr(1),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. All instances of new(int64(1)) in this struct are syntactically incorrect.

Copilot uses AI. Check for mistakes.
Services: escfg.IndexOptions{
Shards: 3,
Replicas: ptr(int64(1)),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(1)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
return config.IndexOptions{
Shards: 3,
Replicas: ptr(int64(3)),
Replicas: new(int64(3)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(3)) is syntactically incorrect. The correct approach would be to use a helper function or inline pointer creation.

Copilot uses AI. Check for mistakes.
Spans: config.IndexOptions{
Shards: 2,
Replicas: ptr(int64(1)),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(1)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
indexTemOps := config.IndexOptions{
Shards: 3,
Replicas: ptr(int64(5)),
Replicas: new(int64(5)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(5)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
indexTemOps := config.IndexOptions{
Shards: 3,
Replicas: ptr(int64(3)),
Replicas: new(int64(3)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(3)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
Indices: config.Indices{
Dependencies: config.IndexOptions{
Replicas: ptr(int64(1)),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(1)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +100
name: "ES version 7", args: Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: new(int64(1)), IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"},
want: "ES version 7",
},
{
name: "Parse Error version 7", args: Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: ptr(int64(1)), IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"},
name: "Parse Error version 7", args: Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: new(int64(1)), IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"},
wantErr: errors.New("parse error"),
},
{
name: "Parse bool error", args: Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: ptr(int64(1)), IndexPrefix: "test", UseILM: "foo", ILMPolicyName: "jaeger-test-policy"},
name: "Parse bool error", args: Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: new(int64(1)), IndexPrefix: "test", UseILM: "foo", ILMPolicyName: "jaeger-test-policy"},
wantErr: errors.New("strconv.ParseBool: parsing \"foo\": invalid syntax"),
},
{
name: "Invalid Mapping type", args: Options{Mapping: "invalid-mapping", EsVersion: 7, Shards: 5, Replicas: ptr(int64(1)), IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"},
name: "Invalid Mapping type", args: Options{Mapping: "invalid-mapping", EsVersion: 7, Shards: 5, Replicas: new(int64(1)), IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"},
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin in struct literal. The new() function takes a type as argument, not a value. All instances of new(int64(1)) are syntactically incorrect.

Copilot uses AI. Check for mistakes.
EsVersion: 7,
Shards: 5,
Replicas: ptr(int64(1)),
Replicas: new(int64(1)),
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid use of new() builtin. The new() function takes a type as argument, not a value. new(int64(1)) is syntactically incorrect.

Copilot uses AI. Check for mistakes.
@yurishkuro yurishkuro merged commit 6f833d9 into jaegertracing:main Feb 20, 2026
67 checks passed
@yurishkuro yurishkuro deleted the go-fix branch February 20, 2026 21:51
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.49%. Comparing base (c51c3d9) to head (20f0e62).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...nal/sampling/samplingstrategy/adaptive/provider.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8074      +/-   ##
==========================================
+ Coverage   95.47%   95.49%   +0.02%     
==========================================
  Files         316      316              
  Lines       16756    16732      -24     
==========================================
- Hits        15997    15979      -18     
+ Misses        593      588       -5     
+ Partials      166      165       -1     
Flag Coverage Δ
badger_v1 9.12% <58.33%> (-0.02%) ⬇️
badger_v2 1.32% <0.00%> (-0.02%) ⬇️
cassandra-4.x-v1-manual 13.30% <33.33%> (-0.02%) ⬇️
cassandra-4.x-v2-auto 1.31% <0.00%> (-0.02%) ⬇️
cassandra-4.x-v2-manual 1.31% <0.00%> (-0.02%) ⬇️
cassandra-5.x-v1-manual 13.30% <33.33%> (-0.02%) ⬇️
cassandra-5.x-v2-auto 1.31% <0.00%> (-0.02%) ⬇️
cassandra-5.x-v2-manual 1.31% <0.00%> (-0.02%) ⬇️
clickhouse 1.40% <0.00%> (-0.02%) ⬇️
elasticsearch-6.x-v1 16.89% <41.66%> (-0.02%) ⬇️
elasticsearch-7.x-v1 16.92% <41.66%> (-0.02%) ⬇️
elasticsearch-8.x-v1 17.07% <41.66%> (-0.02%) ⬇️
elasticsearch-8.x-v2 1.32% <0.00%> (-0.02%) ⬇️
elasticsearch-9.x-v2 1.32% <0.00%> (-0.07%) ⬇️
grpc_v1 8.08% <41.66%> (-0.04%) ⬇️
grpc_v2 1.32% <0.00%> (-0.02%) ⬇️
kafka-3.x-v2 1.32% <0.00%> (-0.02%) ⬇️
memory_v2 1.32% <0.00%> (-0.02%) ⬇️
opensearch-1.x-v1 16.96% <41.66%> (-0.02%) ⬇️
opensearch-2.x-v1 16.96% <41.66%> (-0.02%) ⬇️
opensearch-2.x-v2 1.32% <0.00%> (-0.02%) ⬇️
opensearch-3.x-v2 1.32% <0.00%> (-0.02%) ⬇️
query 1.32% <0.00%> (-0.02%) ⬇️
tailsampling-processor 0.52% <0.00%> (-0.02%) ⬇️
unittests 94.18% <93.33%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sampling changelog:refactoring Internal code refactoring without functional changes go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants