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

cmd/go: actually allow "go run" without any arguments nor flags #36235

Closed
mvdan opened this issue Dec 20, 2019 · 7 comments
Closed

cmd/go: actually allow "go run" without any arguments nor flags #36235

mvdan opened this issue Dec 20, 2019 · 7 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Dec 20, 2019

#22726 was accepted and implemented a while ago. I'm really happy with it, because go run . is pretty useful.

I also understand the point that @rsc brought up about ambiguous flags. Not accepting go run -foo is reasonable, instead forcing the user to write go run -foo . or go run . -foo to clarify if the flag is for the Go tool or for the main package.

However, I don't quite undrestand why go run without any flags or arguments was left out:

$ go run
go run: no go files listed

The only reason I can think of is consistency, to make go run always require file or package arguments. Still, I'd argue that this form alone should be allowed. It's pretty convenient, and we could simply point the user in the right direction if they try to add a flag alone:

$ go run -foo
go run: specify a package or list of Go files to use flags

This would also actually mark the original proposal as implemented. I was pretty confused that the original proposal was accepted and closed, while the very idea in the title was never implemented.

At the very least, if this proposal is rejected, I think the original proposal should be retitled.

/cc @myitcv @rogpeppe @broady @rsc

@gopherbot gopherbot added this to the Proposal milestone Dec 20, 2019
@mvdan
Copy link
Member Author

mvdan commented Sep 16, 2020

This got pretty much all positive feedback and no complaints, so we agreed with @bcmills to just move it to a regular issue to be fixed.

@mvdan mvdan modified the milestones: Proposal, Backlog Sep 16, 2020
@mvdan mvdan changed the title proposal: cmd/go: actually allow "go run" without any arguments nor flags cmd/go: actually allow "go run" without any arguments nor flags Sep 16, 2020
@mvdan mvdan added GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. and removed Proposal labels Sep 16, 2020
@mvdan mvdan self-assigned this Sep 16, 2020
@gopherbot
Copy link

Change https://golang.org/cl/342389 mentions this issue: cmd/go: allow go run without arguments

@rsc
Copy link
Contributor

rsc commented Aug 15, 2021

Please don't do this. It seems like a good idea, and then the very next thing someone wants to do is pass a single argument, whether a flag or not, and it all breaks.

@rsc
Copy link
Contributor

rsc commented Aug 15, 2021

If go run . is not discoverable enough, it would be fine to change the message

go run: no go files listed (use 'go run .' for current package)

@mvdan
Copy link
Member Author

mvdan commented Sep 3, 2021

That's fair. It's been some time since I filed this, and I feel less strongly about it now. We now also have go run pkg@version, so I think it's going to be expected that one always gives arguments to go run.

At the very least, if this proposal is rejected, I think the original proposal should be retitled.

I think we should still do this, though. We have an accepted and closed proposal titled proposal: cmd/go: allow "go run" without arguments, which is clearly not the current state of affairs.

@seankhliao
Copy link
Member

I've retitled the other issue, closing this one as we're not doing it

@go101
Copy link

go101 commented Nov 23, 2021

@seankhliao is there a link to the other one?

@rsc rsc unassigned mvdan Jun 23, 2022
@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants