Session

Go as a scripting language in Linux

Why use Go as a scripting language? Short answer: why not? Go is relatively easy to learn, not too verbose and there is a huge ecosystem of libraries which can be reused to avoid writing all the code from scratch. Some other potential advantages it might bring:

* build your complex Go project with Go-based build system: no Makefiles, bash or Python - all pure Go!
* easy non-privileged package management out of the box: if you want to use a third-party library in your script, you can simply `go get` it to your `GOPATH`
* quick code prototyping on early project stages: short-circuit the *"edit->compile->check"* cycle, instead immediately execute your source file
* fail early with strongly-typed scripting language: if you have a typo in your 2k line script, it will fail to start instead of executing first 1800 lines and leave your system in an inconsistent state

There were previous attempts to make Go scriptable using a shebang line, however (mostly because lines starting with `#` are not valid in Go) the solution is not perfect: you end up with `.go` files either to be used as scripts only or as real compilable Go programs, but not both. This talk describes how one can use some advanced features of binary execution on Linux to overcome previous problems and make Go truly native scripting language.

Ignat Korchagin

Cloudflare, Linux Guru

London, United Kingdom

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top