5 ms·
I love the idea of main-less Go scripts for times where you just want to do something simple, fast. Neugram [1] aimed to make Go a better scripting tool, but u
by maddyboo 6y ago
I love the idea of main-less Go scripts for times where you just want to do something simple, fast.
Neugram [1] aimed to make Go a better scripting tool, but unfortunately it seems the project is dead. Although Go+ says its focus is on data science, I think it could fill this niche too.
By the way: does Go+ have shebang support?
1: https://github.com/neugram/ng https://github.com/neugram/ng
- deleted 6y ago[deleted]
- sa46 6y agoNot main-less but you can run go scripts using a shebang with some elbow grease. https://blog.cloudflare.com/using-go-as-a-scripting-language-in-linux/ https://blog.cloudflare.com/using-go-as-a-scripting-language...
- dgellow 6y ago> I love the idea of main-less Go scripts for times where you just want to do something simple, fast. What do you mean by a main-less script? And what would be "simple and fast" about it? If I want to try out something fast, I just do everything in a main.go and run it with "go run main.go", and that works well as a scripting language.
- uryga 6y ago> What do you mean by a main-less script? probably something that's common in "scripting" languages, where you don't have to wrap your code in main(), it just executes from the top: myscript.py ----------- print('hi') vs myscript.go ----------- func main() { fmt.PrintLn('hi') }
- stevekemp 6y agoGo doesn't need to have shebang support, the kernel will provide that. But for the record it will work: frodo ~ $ cat t.go //opt/go/bin/go run $0 $@ ; exit package main import( "fmt" ) func main() { fmt.Printf("Hello, world\n" ); } frodo ~ $ ./t.go Hello, world Otherwise there are a bunch of go-interpreters out there, which can be used for adhoc scripting. I'm sure that in some circumstances they can be useful, but I've only used them for providing extensions / scripting to host-applications, rather than trying to use them interactively.
- maddyboo 6y agoI’m specifically asking about Go+ (not Go) “having” shebang support in that you can legally use the standard #! shebang. Yes, the kernel handles the shebang, but if the shebang target doesn’t ignore the line and errors then that’s where the problem lies. The workarounds mentioned by you and the other commenter’s linked article are sub-optional in that they require a system-wide modification, require wrapper scripts, or are non-standard hacks.