使用模块时如何让 Travis 更快地构建

How to make Travis go build faster when using modules

我们在一个项目中使用了go modules和travis。每次 Travis 构建项目时,go modules 都会获取所有依赖项,这会增加构建时间。有什么方法可以减少时间或避免每次都获取 deps 吗?

是的,您可以缓存 Go 模块以加快构建过程。

- language: go

  script:
    - your script

  cache:
    directories:
      - $HOME/.cache/go-build        # Cache the binaries
      - $HOME/gopath/pkg/mod         # Cache the Go modules

参考:https://restic.net/blog/2018-09-02/travis-build-cache