No description
  • TypeScript 99.6%
  • Shell 0.2%
  • JavaScript 0.2%
Find a file
George Adams 8f19afcc70
feat: add go-download-base-url input for custom Go distributions (#721)
* feat: add go-download-base-url input for custom Go distributions

Add support for downloading Go from custom sources such as Microsoft Go
(aka.ms). Users can specify a custom download base URL via the
`go-download-base-url` input or the `GO_DOWNLOAD_BASE_URL` environment
variable (input takes precedence).

When a custom URL is provided, the action skips the GitHub-hosted
manifest and attempts to resolve versions from the custom URL's JSON
listing. If the listing is unavailable (as with aka.ms redirect links),
it falls back to constructing the download URL directly from the
version, platform, and architecture.

Usage:
  - uses: actions/setup-go@v6
    with:
      go-version: '1.25'
      go-download-base-url: 'https://aka.ms/golang/release/latest'

Changes:
- action.yml: add go-download-base-url optional input
- installer.ts: add getInfoFromDirectDownload() for URL construction
  fallback, thread custom URL through getGo/getInfoFromDist/findMatch
- main.ts: read new input and GO_DOWNLOAD_BASE_URL env var
- setup-go.test.ts: add 12 unit tests for custom URL behavior
- microsoft-validation.yml: add E2E workflow testing Microsoft build of Go
  across ubuntu/windows/macos with versions 1.24 and 1.25
- README.md: document new input with Microsoft build of Go examples

* run prettier

* fixup PR review

* revert cache-save

* fixup

* handle distinct cache

* skip json for known URL

* fix bug in JSON with custom URL
2026-03-16 12:43:44 -05:00
.github feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
.licenses/npm Bump minimatch from 3.1.2 to 3.1.5 (#727) 2026-03-02 15:43:24 -06:00
__tests__ feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
dist feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
docs feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
src feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
.eslintignore Add and configure ESLint and update configuration for Prettier (#341) 2023-03-08 10:45:16 +02:00
.eslintrc.js Update configuration files 2023-05-23 08:32:03 +00:00
.gitattributes Add and configure ESLint and update configuration for Prettier (#341) 2023-03-08 10:45:16 +02:00
.gitignore starting v2 and proxy support 2020-02-09 00:21:39 -05:00
.licensed.yml Bump minimatch from 3.1.2 to 3.1.5 (#727) 2026-03-02 15:43:24 -06:00
.prettierignore Add and configure ESLint and update configuration for Prettier (#341) 2023-03-08 10:45:16 +02:00
.prettierrc.js Update configuration files (#348) 2023-03-15 00:26:55 +01:00
action.yml feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
CODE_OF_CONDUCT.md Rename CONDUCT.md and change email inside (#218) 2022-04-18 10:45:36 +02:00
CODEOWNERS Update CODEOWNERS 2022-12-26 09:42:22 +01:00
jest.config.js Add setup-go 2019-06-19 09:44:17 -04:00
LICENSE Add setup-go 2019-06-19 09:44:17 -04:00
matchers.json Don't require relative paths to start with ./ or ../ (#98) 2021-12-17 18:47:05 +03:00
package-lock.json Bump minimatch from 3.1.2 to 3.1.5 (#727) 2026-03-02 15:43:24 -06:00
package.json Bump qs from 6.14.0 to 6.14.1 (#703) 2026-01-12 20:41:32 -06:00
README.md feat: add go-download-base-url input for custom Go distributions (#721) 2026-03-16 12:43:44 -05:00
tsconfig.json Add and configure ESLint and update configuration for Prettier (#341) 2023-03-08 10:45:16 +02:00

setup-go

Basic validation Validate 'setup-go'

This action sets up a Go environment for use in GitHub Actions by:

  • Optionally downloading and caching a version of Go by version and adding it to the PATH
  • Optionally caching Go modules and build outputs
  • Registering problem matchers for error output

Breaking changes in V6

The V6 edition of the action includes:

  • Upgraded Node.js runtime from node20 to node24

    Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. See Release Notes

  • Go toolchain

    • Supports both go and toolchain directives in go.mod. If the toolchain directive is present, its version is used; otherwise, the action falls back to the go directive.
  • Cache key update

    • By default, the cache key for Go modules is based on go.mod. To use go.sum, configure the cache-dependency-path input.

See full release notes on the releases page.

Usage

See action.yml.

- uses: actions/setup-go@v6
  with:
    # Version or version range of Go to use
    go-version: '1.23'
    
    # Path to go.mod, go.work, .go-version, or .tool-versions file
    # Note: if both go-version and go-version-file are provided, go-version takes precedence.
    go-version-file: 'go.mod'
    
    # Set this option if you want the action to check for the latest available version
    # Default: false
    check-latest: false
    
    # GitHub token for authentication
    token: ${{ github.token }}
    
    # Used to specify whether caching is needed.
    # Default: true
    cache: true
    
    # Path to dependency files for caching
    cache-dependency-path: 'go.sum'
    
    # Architecture to install (auto-detected if not specified)
    architecture: 'x64'
    
    # Custom base URL for Go downloads (e.g., for mirrors)
    go-download-base-url: ''

Basic:

steps:
  - uses: actions/checkout@v6
  - uses: actions/setup-go@v6
    with:
      go-version: '1.25' # The Go version to download (if necessary) and use.
  - run: go run hello.go

Version resolution behavior:

The action resolves the requested version in the following order:

  1. Local cache - Checks the local tool cache for a matching semver version.
  2. go-versions repository - If the requested version isnt available in the tool cache, it pulls the version manifest from the main branch of the go-versions repository.
  3. Direct download - If that lookup misses or fails, it will fall back to downloading directly from the official Go distribution site.

To change the default behavior, please use the check-latest input.

Note

: The setup-go action uses executable binaries built by the Go team and does not build Go binaries from source code.

Supported version syntax

The go-version input supports the following syntax:

  • Specific versions: 1.25, 1.24.11, 1.24.0-rc.1, 1.23.0-beta.1
  • SemVer version range syntax: ^1.25.1, ~1.24.1, >=1.25.0-rc.1, <1.25.0, >=1.22.0 <1.24.0
  • Aliases: stable, oldstable
  • Wildcards: 1.25.x, 1.x

For details on Semantic Versioning, see the semver package documentation.

Note

: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks:

  go-version: '1.20'

The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious.

For more usage examples, please refer to the section: Using go-version input of the Advanced usage guide.

When using the setup-go action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:

permissions:
  contents: read # access to check out code and install dependencies

Caching dependency files and build outputs

The action includes built-in caching and restoration for Go modules and build outputs. It uses toolkit/cache under the hood, but requires less configuration. The cache input is optional, and caching is enabled by default. To disable caching, set cache: false.

By default, the action looks for go.mod in the repository root and uses its hash as part of the cache key. Use the cache-dependency-path input when you have multiple dependency files, or when theyre located in different subdirectories. This input supports glob patterns.

If caching cannot be performed for any reason, the action logs a warning and continues workflow execution.

For examples of using cache-dependency-path, see the Caching section of the Advanced usage guide.

Advanced usage

License

The scripts and documentation in this project are released under the MIT License.

Contributions

Contributions are welcome! See our Contributor's Guide.

Code of Conduct

👋 Be nice. See our code of conduct