Skip to content

Update go to 1.25.7#4886

Merged
prateekchaudhry merged 10 commits intoaws:devfrom
prateekchaudhry:golang-1.25-upd
Mar 6, 2026
Merged

Update go to 1.25.7#4886
prateekchaudhry merged 10 commits intoaws:devfrom
prateekchaudhry:golang-1.25-upd

Conversation

@prateekchaudhry
Copy link
Contributor

@prateekchaudhry prateekchaudhry commented Mar 3, 2026

Summary

Update golang version to 1.25.7. Also make necessary changes to support unit testing with golang 1.25. These changes are needed because GOEXPERIMENT=nocoverageredesign flag is no longer supported.

Implementation

  • Main change is to update golang version to 1.25.7 in GO_VERSION, GO_VERSION_WINDOWS and spec files
  • With go 1.25, GOEXPERIMENT=nocoverageredesign is no more supported. For context, this flag turns off the way golang calculates go cover by default since go 1.22 onwards and was introduced in a previous PR - update go to 1.22.3 #4184 . However, the fix was temporary. Since now the flag is no more supported.
  • With new default (that is without the nocoverageredesign flag), test coverage gets diluted by autogenerated code - packages such as mocks, interfaces, etc, which do not have any tests. While previously, packages which did not have any tests did not contribute to coverage at all, with new default, they contribute 0 to coverage and some number of lines to inflate the code size, bringing down test coverage.
    (https://go.dev/doc/go1.22)
go test -cover now prints coverage summaries for covered packages that do not have their own test files. Prior to Go 1.22 a go test -cover run for such a package would report

? mymod/mypack [no test files]

and now with Go 1.22, functions in the package are treated as uncovered:

mymod/mypack coverage: 0.0% of statements
  • We fix it by using coverpkg flag. When calculating test cover, we pass all the packages which actually have tests for them to the go test command to measure test coverage. This flag measures cross package test coverage against only the packages provided.
  • We also introduce no-test lists for packages against which we do not want to measure coverage against. These packages are mostly mocks or interfaces.
  • Since with coverpkg testing is cross package, and within those packages, the actual test coverage reported goes up slightly with this change. This is possibly more correct too.
  • Also: Some ecs-init engine tests were behind build tags and never ran in GH Actions. Removed the tags and added AppArmor mock so they run correctly on GitHub Actions.

Testing

Test coverage with GOEXPERIMENT=nocoverageredesign and golang 1.24

  • /agent - 75.7%
  • /ecs-agent - 71.2%
  • /ecs-init - 77.8%

Test coverage with -coverpkg and golang 1.25

  • /agent - 82.7%
  • /ecs-agent - 77.4%
  • /ecs-init - 79.0%

Description for the changelog

Enhancement - Update go version to 1.25.7

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

sparrc
sparrc previously approved these changes Mar 3, 2026
mye956
mye956 previously approved these changes Mar 5, 2026
@prateekchaudhry prateekchaudhry merged commit 0523c2d into aws:dev Mar 6, 2026
43 of 45 checks passed
@prateekchaudhry prateekchaudhry mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants