Member-only story

Preparing an Offline Golang Development Environment

Zhimin Wen
4 min readJun 10, 2022

--

Image by vek0 from Pixabay

I need to perform some quite extensive deployment tasks in an air-gapped environment. My approach will be automation, automation, and automation achieved with magefile and sshkit.

However since it's air-gapped, we will need to prepare our toolings first.

Offline Golang Module Dependency

Let’s prepare the module dependencies and prepackage them with “go vendor”.

go init mod airgap-packages
mkdir magefiles
cd magefiles
touch mods.go main.go

In the mods.go, includes all the required dependency modules,

package mainimport (
_ "github.com/dsnet/try"
_ "github.com/magefile/mage/mg"
_ "github.com/zhiminwen/magelib/tunnel"
_ "github.com/zhiminwen/magetool/shellkit"
_ "github.com/zhiminwen/magetool/sshkit"
_ "github.com/zhiminwen/quote"
_ "gopkg.in/yaml.v2"
)

Create a skeleton main program,

package mainimport (
"os"
"github.com/dsnet/try"
"github.com/zhiminwen/magetool/sshkit"
)
var bastion *sshkit.SSHClientfunc init() {
os.Setenv("MAGEFILE_VERBOSE", "true")
bastion =…

--

--

No responses yet