`go version` is run before downloading the cache, but if this is run
with a version of `go` that triggers a Toolchain download[1], e.g. if
the installed Go is 1.20.0 but `go.mod` has a toolchain directive
`go1.20.1` then a toolchain is downloaded to e.g.
`$GOMODCACHE/golang.org/toolchain@v0.0.1-go1.21.1.linux-amd64`, if this
file already exists in the cache (e.g. this is the second run of this
action we not cache invalidation) then the cache download will try and
overwrite these files resulting in noisy errors like:
/usr/bin/tar: ../../../go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.6.linux-amd64/lib/time/mkzip.go: Cannot open: File exists
Instead, force `go` to use the local toolchain (i.e. the one the one
that shipped with the go command being run) via setting the
`GOTOOLCHAIN` environment variable[1]:
> When GOTOOLCHAIN is set to local, the go command always runs the
bundled Go toolchain.
This addresses https://github.com/actions/setup-go/issues/424
[1] https://go.dev/doc/toolchain#select
* Fix Install on Windows is very slow
* Add unit test
* Improve readability
* Add e2e test
* fix lint
* Fix unit tests
* Fix unit tests
* limit to github hosted runners
* test hosted version of go
* AzDev environment
* rename lnkSrc
* refactor conditions
* improve tests
* refactoring
* Fix e2e test
* improve isHosted readability
Using the explicit filename for Windows is necessary to
satisfy `Expand-Archive`'s requirement on '.zip' extension.
Signed-off-by: Javier Romero <root@jromero.codes>
* Add go-version to action outputs
This provides the semver version of Go that has been installed. This is useful
if only a major or minor version has been provided as the input go-version
value.
* Convert version extraction to a function
Simplify how the version is extracted and add a simple test at the same
time.
Co-authored-by: Peter Mescalchin <peter@magnetikonline.com>
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
Co-authored-by: Peter Mescalchin <peter@magnetikonline.com>
Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com>
This has not been necessary since [Go 1.9](https://go.dev/doc/go1.9#goroot) at
least (although clunky to do so then) but definitely not since
[Go 1.10](https://go.dev/doc/go1.10#goroot).
This is cargo culting code that is more than 2 years out of date and runs into
issues when multiple go versions are used in an action run.
Signed-off-by: Manuel Mendez <mmendez534@gmail.com>