Skip to content

Instantly share code, notes, and snippets.

@ps23
Last active September 1, 2018 21:41
Show Gist options
  • Save ps23/cae68c480ad929227a4864ffc804186b to your computer and use it in GitHub Desktop.
Save ps23/cae68c480ad929227a4864ffc804186b to your computer and use it in GitHub Desktop.

Setup go and sample go project outside GOPATH

[[ -r ~/.bashrc ]] && . ~/.bashrc
source ~/.profile
export GOPATH=$HOME/.go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
#!/usr/bin/env bash
set -ex
echo "Please enter your golang path (ex: $HOME/.go) :"
read gopath
mkdir $gopath
export GOPATH=$gopath
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install go
brew install git
brew install dep
go get golang.org/x/tools/cmd/godoc
set +ex
#!/bin/sh
set -ex
PROJECT=<YOUR PROJECT NAME>
PROJECT_PATH=${GOPATH}/src/<PATH TO PROJECT W/O PROJECT FOLDER>
WORK_PATH=${PWD}
mkdir -p ${PROJECT_PATH}
if [ ! -e ${PROJECT_PATH}${PROJECT} ]; then ln -s ${WORK_PATH} ${PROJECT_PATH}${PROJECT}; fi
cd ${PROJECT_PATH}${PROJECT}
go get -d ./...
go install
dep init || true && dep ensure
cd ${WORK_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment