Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

The possibilty run go source code as real scripts

272 views
Skip to first unread message

Lin Lin

unread,
Nov 22, 2024, 4:27:10 AM11/22/24
to golang-nuts

Jeremy French

unread,
Nov 22, 2024, 7:06:36 PM11/22/24
to golang-nuts
As a firm advocate for Go, I do not think Go is a good choice for what you're trying to do. Maybe if you wanted to just use a JIT compiler for your scripts?  Since Go compiles so fast, you may not even notice the compile time for small, 500-line "scripts".  Otherwise, if it has to be interpreted on the fly, you should probably choose the right tool for the job, of which Python is a pretty good choice, or Node (though, I think maybe that's compiled JIT too).  If you're running into limitations, etc, that's probably the nature of an interpreted tool chain.  This might be an X-Y problem.

tapi...@gmail.com

unread,
Nov 23, 2024, 2:41:39 AM11/23/24
to golang-nuts
There is certainly such need. But since Go 1.22, it is highly recommended not to do this.
Please read:
 

Jason E. Aten

unread,
Nov 23, 2024, 8:30:12 AM11/23/24
to golang-nuts
I would just write a command-line utility in Go using the https://pkg.go.dev/flag package.

Brian Candler

unread,
Nov 23, 2024, 4:59:56 PM11/23/24
to golang-nuts
Have you looked at this?

It supports shebang execution of scripts, and it seems to be maintained: "Support the latest 2 major releases of Go (Go 1.21 and Go 1.22)"

Lin Lin

unread,
Nov 24, 2024, 7:37:51 PM11/24/24
to Brian Candler, golang-nuts
Thanks Brian. I've checked that, it probably what I want. I don't know how I missed it.

Thanks again.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/6a55587b-19fb-4577-aa9c-3a534d7d0e31n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages