Skip to content

Instantly share code, notes, and snippets.

@johnjansen
Last active August 21, 2016 10:29
Show Gist options
  • Save johnjansen/ab89b8ecccf40453e996 to your computer and use it in GitHub Desktop.
Save johnjansen/ab89b8ecccf40453e996 to your computer and use it in GitHub Desktop.
Try Golang, without Golang

Experiment with golang without polluting your local

  1. install docker ... really, you need to look at containers !!!

  2. docker pull golang

  3. 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
    
  4. write some code and build it read the tut's

        go build [...]
    
  5. 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 "
    
  6. now run that app you compiled

        gorun ./myapp
    
  7. 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
    
  8. 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

@dreamware

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment