Using official golang docker image

Install dependencies with Go modules

pipeline:
  dependencies:
    image: golang:1.11
    commands:
      - go get

Install dependencies with dep

pipeline:
  dependencies:
    image: instrumentisto/dep:0.5.0
    commands:
      - dep ensure -v -vendor-only

Run go build

pipeline:
  build:
    image: golang:1.11
    commands:
      - go build

Run go build with environment

pipeline:
  build:
    image: golang:1.11
    environment:
      # https://golang.org/cmd/go/#hdr-Environment_variables
      - CGO_ENABLED=0 # Turn cgo off
    commands:
      - go build -ldflags "-X main.version={{ .CICD_COMMIT }}"

Run go tests and lint tools

pipeline:
  test:
    image: golang:1.11
    commands:
      - go test -v
      - go fmt

Read more how to use this image on docker docs