Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Action failing with latest golang:alpine image #5

Closed
caitlinelfring opened this issue Mar 19, 2022 · 2 comments · Fixed by #6
Closed

Action failing with latest golang:alpine image #5

caitlinelfring opened this issue Mar 19, 2022 · 2 comments · Fixed by #6

Comments

@caitlinelfring
Copy link

caitlinelfring commented Mar 19, 2022

I discovered this failing in the latest golang:alpine image that's used in this action - example. I haven't run this action in a while, but golang:alpine is now go 1.18. Testing this action locally with golang:1.17-alpine works as expected.

go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.

From the changelog of 1.18 - https://tip.golang.org/doc/go1.18#go-get

go get no longer builds or installs packages in module-aware mode. go get is now dedicated to adjusting dependencies in go.mod. Effectively, the -d flag is always enabled. To install the latest version of an executable outside the context of the current module, use go install example.com/cmd@latest. Any version query may be used instead of latest. This form of go install was added in Go 1.16, so projects supporting older versions may need to provide install instructions for both go install and go get. go get now reports an error when used outside a module, since there is no go.mod file to update. In GOPATH mode (with GO111MODULE=off), go get still builds and installs packages, as before.

go get is still the recommended way to update a package https://pkg.go.dev/about#adding-a-package

Wondering if you might have a recommendation for how to move forward. My workaround is to run the commands in this action myself so I can force go 1.17.

Thanks for your help!

@andrewslotin
Copy link
Owner

Hey @caitlinelfring, good catch and a very informative description. Indeed, go get seems to have stopped operating outside of module context starting from go1.18. I'm going to release a new version of this action to address this issue.

andrewslotin added a commit that referenced this issue Mar 21, 2022
Since go1.18 the behavior of `go get` has changed to operate within module context only. In case there is no `go.mod` present in the current directory, command returns with a non-zero status, which terminates the execution and fails the action.

To address this issue we're going to init a dummy module before running `go get`, which will add the target package to the `go.mod` and download it via proxy. The change should be backward-compatible with older Go versions that have module support.

Closes #5
@andrewslotin
Copy link
Owner

Please give v1.0.3 a try and let me know if this resolves your issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants