golangProfile

21st March 2017 at 4:06pm
golang
if [ -x /usr/local/go/bin/go ] ; then
  GOROOT="/usr/local/go"
  PATH="$PATH:/usr/local/go/bin"
  export GOROOT
  export PATH
fi

if [ -x "$HOME/go/bin/go" ] ; then
  if [ -n "$GOROOT" ] ; then
    echo "GOROOT was already set to $GOROOT; resetting to $HOME/go" >&2
  fi
  GOROOT="$HOME/go"
  PATH="$PATH:$GOROOT/bin"
  export GOROOT
  export PATH
fi

if [ -d "$HOME/go" ] ; then
  GOPATH="$HOME/go"
  export GOPATH
fi

if [ -d "$HOME/src/go" ] ; then
  if [ -n "$GOPATH" ] ; then
    echo "GOPATH was already set to $GOPATH; resetting to $HOME/src/go" >&2
  fi
  GOPATH="$HOME/src/go"
  export GOPATH
fi

if [ -n "$GOPATH" ] && [ -d "$GOPATH/bin" ] ; then
  GOBIN="$GOPATH/bin"
  export GOBIN
fi

if [ -n "$GOBIN" ] && [ -d "$GOBIN" ] ; then
  PATH="$PATH:$GOBIN"
  export PATH
fi