Last active
February 3, 2018 20:59
-
-
Save ball6847/b526d4a70fe0853c06215abad95e5f2b to your computer and use it in GitHub Desktop.
setup go workspace separated from $GOROOT using direnv, make it work nicely with gvm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| # assuming you've already installed GO and direnv | |
| # and your desired workspace is at $HOME/go-workspace | |
| # first, create workspace skeleton and go to workspace | |
| mkdir -p ~/workspace/{bin,src,pkg} | |
| cd ~/workspace/ | |
| # create .envrc with predefined layout (direnv built-in layout) | |
| echo 'layout go' > .envrc | |
| # trust this .envrc (required for first run) | |
| dirnev allow | |
| # and then, anytime you enter your workspace or its child directory | |
| # direnv will automatically load workspace path into environment variable | |
| # start working on a package | |
| # let's try https://github.com/OscarYuen/go-graphql-starter | |
| cd src/ | |
| git clone git@github.com:OscarYuen/go-graphql-starter.git github.com/OscarYuen/go-graphql-starter | |
| cd $_ | |
| # it works pretty well. ;) | |
| dep ensure |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This also works
Then put this into your ~/.zshrc