Open ericcurtin opened 6 years ago
@ericcurtin one option is to run it as comments, then you can run go fmt
on it fine:
//usr/bin/env gorun "$0" "$@"; exit "$?"
package main
func main() {
println("Hello worldz!")
}
For various other solutions and tradeoffs see: https://gist.github.com/posener/73ffd326d88483df6b1cb66e8ed1e0bd
Somehow this also works and gofmt won't change the code. It adds a space after the comment
// / 2>/dev/null ; gorun "$0" "$@" ; exit $?
Somehow this also works and gofmt won't change the code. It adds a space after the comment
Just add an empty line before this gorun
line and a package main
line. This way this comment won't be considered a "package comment" and gofmt won't change it.
A C/C++ programmer primarily, looking to learn something new, golang! One of the things I first thought is what great potential it had as a statically typed scripting language! And I really like how you cache compiled binaries here, pretty cool.
Anyway long story short... I'd like to introduce a "gorun fmt" option to format my gorun scripts... Because if you pass through normal go fmt it doesn't like the shebang of course:
If I open a PR would you except a "gorun fmt" option? Don't want to waste effort if it wouldn't be accepted!