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: fix error for go run of files in different directories #9853

Closed
tcurdt opened this issue Feb 12, 2015 · 5 comments
Closed

cmd/go: fix error for go run of files in different directories #9853

tcurdt opened this issue Feb 12, 2015 · 5 comments
Milestone

Comments

@tcurdt
Copy link

tcurdt commented Feb 12, 2015

Based on

$ go run --help
usage: run [build flags] [-exec xprog] gofiles... [arguments...]

I would have thought that it would be OK to run go files like

go run main.go folder/*.go

but for reasons I don't understand it tries to find the file folder/main.go instead (and obviously fails). All files are in the main package.

It would be nice to allow arbitrary paths to the go files.
If that's out of question at least the docs and error message should be improved.

http://golang.org/doc/code.html
https://golang.org/cmd/go/#hdr-Compile_and_run_Go_program

@nightlyone
Copy link
Contributor

go run foo.go is intented for quick, one off, single file programs. Like a small proof of concept, dirty hack, etc.

Try making a package of folder/*go and import it as normal from your main.go file.

I don't think this will be further extended...

@tcurdt
Copy link
Author

tcurdt commented Feb 12, 2015

That's certainly an option.

In my case it's still not much more than a dirty hack that grew and is now spread across multiple files. To clean up I started to put things in folders and suddenly go run was no longer an option.

If this is not to be supported then at least expectations and error messages should be adjusted.
Then go run should only allow files in the local dir and have that documented.

Either it should be done right or made clear it's no option. I don't really see a middle ground here.

@minux
Copy link
Member

minux commented Feb 12, 2015 via email

@tcurdt
Copy link
Author

tcurdt commented Feb 12, 2015

Well, then I am all for fixing the error message. And maybe be a little more explicit in the docs.
Given how most Unix/Linux commands the expectation of accepting paths instead of just files is real.

@adg adg changed the title go run with multiple dirs cmd/go: more intuitive error message on 'go run' with multiple dirs Feb 12, 2015
@rsc rsc changed the title cmd/go: more intuitive error message on 'go run' with multiple dirs cmd/go: fix error for go run of files in different directories Apr 10, 2015
@rsc rsc added this to the Go1.5 milestone Apr 10, 2015
@gopherbot
Copy link

CL https://golang.org/cl/12149 mentions this issue.

@rsc rsc closed this as completed in 3585f21 Jul 15, 2015
@golang golang locked and limited conversation to collaborators Jul 18, 2016
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