-
install docker ... really, you need to look at containers !!!
-
docker pull golang
-
pretend we have go installed
echo 'alias go="docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang go "' >> ~/.bash_profile source ~/.bash_profile
-
write some code and build it read the tut's
go build [...]
-
think some more ... lets change that bit in ~/.bash_profile
alias gorun="docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang " alias go="gorun go "
-
now run that app you compiled
gorun ./myapp
-
consider what you have just achieved .. maybe delete go completely, or install it properly .. either way, you just ran a compiler in a container, without polluting your pristine local machine
# recover that disk space by removing the golang image docker rmi golang
-
you may well have a compiled binary in the directory with your go code ... it probably wont run directly on local so
rm
that
Thats all enjoy ... and bye
PS ... remember to remove those aliases from ~/.bash_profile when you are done