Caching module downloads in Continuous Integration (CI) can greatly improve build times and reduce the load on your internet connection. By storing previously downloaded modules, you can avoid regenerating the same artifacts over and over again. This guide illustrates how to achieve effective caching in your CI pipeline using tools such as GitHub Actions, GitLab CI, or CircleCI.
In GitHub Actions, you can use the `actions/cache` action to cache your Go module files. Below is an example of how to set it up in your workflow file:
name: Go CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache Go modules
uses: actions/cache@v2
with:
path: /path/to/your/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/*.go') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
- name: Install dependencies
run: go mod download
- name: Run tests
run: go test ./...
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?