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.

On Friday, November 22, 2024 at 4:27:10 AM UTC-5 Lin Lin wrote:

> Hi, gophers, here is our dilemma.
>
> We build system managing infrastructure such as Kubernetes. With that 
> comes the need to write
> a lot of maintenance scripts. For now they are all written in Bash, which 
> is hard to edit and test. 
> As the community suggests, do not write Bash code more than 100 lines. The 
> file we wrote is more than 500 lines.Another option is to use Python, a 
> better choice, but has its own disadvantages. When we need some 
> capabilities beyond the standard libraries, we need to add
>  pip rpms. The dependency is a mess and can easily corrupt the OS.
>
> That's when I started to consider Go might be an option as long as we can 
> get rid of the compiling part. 
>
> Here is the ideal Go script interpreter I wish.
>
> 1. It is a gosh like bash binary residues in the system.
> 2. It can invoke a script.go file, dynamically parse and execute the 
> statements.
> 3. It can only support those functions and libraries compiled earlier into 
> itself.
> 4. It can be easily added with any libraries in advance.
> 5. The source file is exactly the same with normal go source files, and 
> can be compiled into its own separate binary.
>
> Such an interpreter can be very stable for a Bash alternative. All you 
> need is a gosh, all 
> other Go fmt, vet, vulcheck can seamlessly inherit. And it comes with a 
> very little overhead 
> for Go developers to learn and use.
>
> As far as I know, there is no such project.
>
> https://github.com/matryer/goscript is a similar one but seems out of 
> date and depends on go toolchain;
> https://github.com/bitfield/script is really not a go-style one, too 
> bash-ish.
>
> Can this be a real need? Is there any difficulties in bringing it into the 
> real world?
> I'd like to hear from you gophers, thanks.
>
> Best wishes.
>
> Lin
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/898b2afd-ed9d-4cf0-8693-4b5df0795392n%40googlegroups.com.

Reply via email to