Toshimaru's Blog

Enable Go Module Cache on TravisCI

Enbale Go Module Cache on TravisCI

To enbale Go module cache, set $GOPATH/pkg/mod as TravisCI cache directory.

.travis.yml:

cache:
  directories:
    - $GOPATH/pkg/mod

Whole .travis.yml Sample

.travis.yml:

language: go
go:
  - "1.12.x"
cache:
  directories:
    - $GOPATH/pkg/mod
env:
  global:
    - GO111MODULE=on
install:
  - go mod download
script:
  - go test ./...

Reference