How to Set Up a CI/CD Pipeline for Go (GitHub Actions)

Set up a GitHub Actions workflow to automatically build and test your Go code on every push or pull request.

Create a .github/workflows/ci.yml file in your repository root to define the build, test, and lint steps for your Go project.

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: 'stable'
      - name: Build
        run: go build -v ./...
      - name: Test
        run: go test -v ./...