-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgo_use_fixup_env
More file actions
executable file
·26 lines (20 loc) · 873 Bytes
/
Copy pathgo_use_fixup_env
File metadata and controls
executable file
·26 lines (20 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# Fills in the paths necessary to use go.
# This file is meant to be sourced,
# source `which go_use_fixup_env`
# or used before calling subshells
# Set this variable for your preferences.
GOPATHBASE=~/Code/gopath
GOVER=$(cat ~/.go_ver)
GOVERSION=$(brew list ${GOVER} | grep '/bin/go' | head -n 1 | cut -d '/' -f 6)
export GOROOT=$(brew --prefix)/Cellar/$GOVER/$GOVERSION/libexec
export GOPATH="$GOPATHBASE/$GOVER"
# Insert our GOROOT's bin at the front of $PATH
DUPLICATEHEAVYPATH=$GOROOT/bin:$GOPATH/bin:$PATH:
FINALPATH=$DUPLICATEHEAVYPATH
# Uncomment this line to purge duplicates from your $PATH.
#FINALPATH=$(echo -n $DUPLICATEHEAVYPATH | awk -v RS=: '{ if (!arr[$0]++) {printf("%s%s",!ln++?"":":",$0)}}')
# Reference: http://unix.stackexchange.com/a/40755/129409
export PATH=$FINALPATH
GOVERLONG=$(go version)
echo "Using ${GOVERLONG} at ${GOPATH}"