Making Go scriptable

Next, prepare the next tool, gorun, to make a Go program scriptable. With gorun, you can add a shebang to the first line of the script, as shown in the following command:

#!/usr/bin/env gorun

The normal Go program will then be allowed to execute directly from the shell.

To install gorun, just do go get. The gorun binary will now be available under the path provided by the current go1.9.3 managed by GVM. Please note that if you switch Go version with GVM, you need to do go get again:

$ go get github.com/erning/gorun

We could install all necessary libraries for controlling Docker programmatically by installing the Docker client library itself:

$ go get github.com/docker/docker/client

If nothing goes wrong, we will be ready to start writing a Golang script.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset