No description
Find a file
oss-core-libraries-dashboard[bot] 27ad193604
[COMPLIANCE] Update Copyright and License Headers (#6)
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
2026-01-15 10:14:05 +01:00
action.yaml action: handle setup-go enabling a cache by default (#4) 2024-01-11 08:27:47 -06:00
CONTRIBUTING.md repo: add a contributing file 2022-11-10 11:05:56 -06:00
LICENSE [COMPLIANCE] Update Copyright and License Headers (#6) 2026-01-15 10:14:05 +01:00
NOTICE.txt repo: add mpl2 legal header 2022-11-10 11:14:18 -06:00
README.md docs: fixes for readme 2022-10-29 15:36:35 -05:00

setup-golang (GitHub action)

GitHub

A composite GitHub action for setting up Go compiler and module cache

  • configures Go compiler using actions/setup-go
  • configures Go modules cache using actions/cache
  • configures GOBIN environment variable to be on $PATH
  • compatible with Linux, Darwin, and Windows runners

Inputs

  • version-file - Either .go-version (default) or go.mod. Used to determine the version of Go compiler to configure.
  • cache-key - Key used to share (or not share) module cache across later actions.

Environment

  • GOBIN - Sets $GOBIN to a value on $PATH
    • currently uses $(go env GOROOT)/bin

Cache Limit

Note that GitHub limits repositories to have up to 10GiB of caches. Once the limit is exceeded, older caches will be evicted on an LRU basis.

Usage

minimal example

This example uses the default values (uses .go-version for the Go version and default as the cache key).

steps:
  - uses: hashicorp/setup-golang@v1

This example uses custom values (uses go.mod for the Go version and mykey as the cache key).

complete example

steps:
  - uses: actions/checkout@v3
  - uses: hashicorp/setup-golang@v1
    with:
      version-file: go.mod
      cache-key: mykey

Cross Platform

The cache automatically keys on operating system. The cache is not shared between Linux, Darwin, and Windows runners.