Skip to content

golang docker image based CI jobs may not be using the expected go version #36080

@BenTheElder

Description

@BenTheElder

The golang docker image sets GOTOOLCHAIN=local which means unless something else sets GOTOOLCHAIN env, go will prefer the version in the docker image. The default GOTOOLCHAIN value in a local go install is GOTOOLCHAIN=auto (go env GOTOOLCHAIN will show this)

Setting it to local makes sense if you want to tightly control the go version from the environment by selecting the docker image version.

In most of our projects, I think we expect that with GOTOOLCHAIN support, CI will behave like local development, and use the version of go selected by the project (through go.mod or other means) so they don't have to update CI config constantly, and having CI use the same version is just to avoid having to download go again at runtime.

GOTOOLCHAIN=auto means you can test updating go in a PR to the repo under test.

For our own images, I sent updates:

There may be other images that require this update, and there are jobs that use the golang images directly.

For jobs that use golang directly, and use >= go 1.21, we should consider setting GOTOOLCHAIN=auto

I think could technically set it as a ci-wide default to be overridden by the jobs, the same way we set GOPROXY:

# enable GOPROXY by default
- env:
- name: GOPROXY
value: "https://proxy.golang.org"

This uses a preset that targets all jobs by not having a specific selector.
That feature may be a little surprising though, and I'm not actually sure the order of defaulting if a job attempts to override it in CI config on the pod spec versus within the job's scripts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions