Navigation Menu

Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

proposal: cmd/go: enable to specify a version with @ like go run and go install #55012

Closed
hajimehoshi opened this issue Sep 12, 2022 · 6 comments

Comments

@hajimehoshi
Copy link
Member

Now

go build github.com/foo/bar@v1.0.0

is not possible:

package github.com/foo/bar@v1.0.0: can only use path@version syntax with 'go get' and 'go install' in module-aware mode

It would be useful and more consitent with other Go tools, if we could build with a specific version.

@gopherbot gopherbot added this to the Proposal milestone Sep 12, 2022
@hajimehoshi hajimehoshi changed the title proposal: cmd/go: enable to specify a version with @ like go run and go instlal proposal: cmd/go: enable to specify a version with @ like go run and go install Sep 12, 2022
@mattn
Copy link
Member

mattn commented Sep 12, 2022

Does this mean that go.mod in the current directory is ignored? So do you expect the executable module to be generated in the current directory even though go.mod does not exist?

@hajimehoshi
Copy link
Member Author

hajimehoshi commented Sep 12, 2022

Does this mean that go.mod in the current directory is ignored?

Yes, like go run and go install that already ignore the current go.mod when @version is specified.

So do you expect the executable module to be generated in the current directory even though go.mod does not exist?

Yes.

@mvdan
Copy link
Member

mvdan commented Sep 12, 2022

I don't disagree with this proposal, but note that you can sort of get a similar result via GOBIN="$PWD" go install pkg@version.

@hajimehoshi
Copy link
Member Author

hajimehoshi commented Sep 12, 2022

GOBIN="$PWD" go install pkg@version.

Good point, but this doesn't work with GOOS and GOARCH:

$ GOBIN=/Users/hajimehoshi GOOS=js GOARCH=wasm go install -tags=example github.com/hajimehoshi/ebiten/v2/examples/blocks@v2.4.2
go: cannot install cross-compiled binaries when GOBIN is set

@mvdan
Copy link
Member

mvdan commented Sep 12, 2022

Huh, that's the first time I'm made aware of that error :) Then I take it back, it's not really a good substitute in general.

@seankhliao
Copy link
Member

Duplicate of #44469

@seankhliao seankhliao marked this as a duplicate of #44469 Sep 12, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2022
@golang golang locked and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants