CI for Go
Build, lint, and test a Go application using standard library tooling.
Use template →1steps:
2 - label: ":golang: Install dependencies"
3 key: "deps"
4 command: "go mod vendor"
5 plugins:
6 - artifacts#v1.9.3:
7 upload: "vendor"
8 compressed: vendor.tgz
9 - docker#v5.9.0:
10 image: "golang:1.22"
11
12 - label: ":golang: Build"
13 command: "go build -mod=vendor main.go"
14 depends_on: ["deps"]
15 plugins:
16 - artifacts#v1.9.3:
17 download: "vendor"
18 compressed: vendor.tgz
19 - docker#v5.9.0:
20 image: "golang:1.22"
21
22 - label: ":golang: Test"
23 command: "go test -mod=vendor ./..."
24 depends_on: ["deps"]
25 plugins:
26 - artifacts#v1.9.3:
27 download: "vendor"
28 compressed: vendor.tgz
29 - docker#v5.9.0:
30 image: "golang:1.22"
31
32 - label: ":golang: Generate"
33 depends_on: ["deps"]
34 command:
35 - "go generate -mod=vendor ./..."
36 - "git diff --exit-code || (echo 'Generated code is out of date, please run `go generate` and commit the changes' && exit 1)"
37 plugins:
38 - artifacts#v1.9.3:
39 download: "vendor"
40 compressed: vendor.tgz
41 - docker#v5.9.0:
42 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.