Golang upgrades
Updating golang version for jenkins x
Jenkins X codebase uses Golang/Go. New versions of golang comes every 6 months, and golang supports only 2 versions. It is highly desireable to use the latest and greatest version of golang for Jenkins X as newer versions have performance improvements and get regular security updates.
To update golang version in Jenkins X follow these steps
- Open an issue in jx repository announcing the upgrade.
- Change the go version in the pipeline catalog repository. See this PR for which files to change.
- Update the catalog version in the version stream See this PR for which files to change.
- Update the library packages first (please follow this order)
- Once these packages are upgraded, start the upgrade for the plugins and main jx repository
- Follow these steps to upgrade the version
- Change the version in go.mod file
- Upgrade any direct dependencies to other Jenkins X packages that you see in go.mod: If you for example find the line
github.com/jenkins-x/jx-logging/v3 v3.0.7
you run go get -u github.com/jenkins-x/jx-logging/v3 - Run
go mod tidy
and ensure that it does not error out - Change
GO_VERSION
in makefile to the version you are upgrading to. - Check if there are any references to an older version and replace those.
- Verify that
- the build works by running
make build
- tests are working, by running
make test
- linting checks are working by running
golangci-lint run
- Use the same version that is used by Jenkins X. At the time of writing that is 1.58; you can see what image version is referenced in the pipeline.
- If there is a configuration file for golangci-lint in the repository (
.golangci.yaml
) it likely needs to be updated. See for example https://github.com/jenkins-x/jx-kube-client/blob/main/.golangci.yml for reference.
- the build works by running
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified June 13, 2024: docs: wording adjustmnet in go-upgrades.md (7bab27b469)