CI for Go
Build, lint, and test a Go application using standard library tooling.
Use template →1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
steps: - label: ":golang: Install dependencies" key: "deps" command: "go mod vendor" plugins: - artifacts#v1.9.3: upload: "vendor" compressed: vendor.tgz - docker#v5.9.0: image: "golang:1.22" - label: ":golang: Build" command: "go build -mod=vendor main.go" depends_on: ["deps"] plugins: - artifacts#v1.9.3: download: "vendor" compressed: vendor.tgz - docker#v5.9.0: image: "golang:1.22" - label: ":golang: Test" command: "go test -mod=vendor ./..." depends_on: ["deps"] plugins: - artifacts#v1.9.3: download: "vendor" compressed: vendor.tgz - docker#v5.9.0: image: "golang:1.22" - label: ":golang: Generate" depends_on: ["deps"] command: - "go generate -mod=vendor ./..." - "git diff --exit-code || (echo 'Generated code is out of date, please run `go generate` and commit the changes' && exit 1)" plugins: - artifacts#v1.9.3: download: "vendor" compressed: vendor.tgz - docker#v5.9.0: image: "golang:1.22"
- Languages
- Go
- Use cases
- Continuous integration, Web application
- Platforms
- Docker
CI for Go
This template provides a continuous integration (CI) pipeline that builds and tests a Go application.
At a glance:
- For Golang applications
- Requires Docker
- Runs Go's standard library commands to build, test, and generate
How it works
This template:
- Downloads Go dependencies using
go mod vendor
and caches them for use across subsequent steps. - Builds the module.
- Runs the tests.
- Ensures the generated code is up.
The runtime environment uses the official Golang Docker image with the latest version.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your Go module.
- Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.