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: run does not support Go scripts without .go extension #26848
Comments
I'm going to ask the perhaps obvious question - why do you need this? In general, all Go files should have the If you're having issues because this file is a Having said all that, I agree in a way that |
This look intentional. It's even explicitly documented:
Stress on
|
Correction: on tip the doc has been changed to:
|
@mvdan, need is a strong word for it, but (edit: as far as I was aware) The Google Style Guide for bash scripts says it's strongly preferred to not have a filename extension on the scripts. Here's some discussion of the topic on an Ubuntu forum: https://askubuntu.com/questions/503127/should-i-save-my-scripts-with-the-sh-extension. Python allows this:
So does Bash:
So does Perl, and it's recommended for perl as well. The point is that it should be possible to run one of these Go scripts like it's a program, and whoever runs it shouldn't have to care what language it's written in if it has a shebang line (or Go's equivalent). |
Go is not a scripting language, and That there are no "Go scripts" is especially obvious due to the fact that shebangs are not supported, intentionally. The issue tracker is filled with discussions about the lack of shebang support, which ties into the whole "there's no Go scripting" issue. Finally, supporting this syntax would preclude adding support for Edit: and like @ALTree has pointed out earlier, |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.3 darwin/amd64
Does this issue reproduce with the latest release?
It gives a different error.
What operating system and processor architecture are you using (
go env
)?I don't think this matters.
What did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: