Last Updated: February 25, 2016
·
1.319K
· boopathi

Set Golang environment before you start with go code

###
#
# @usage   `source set_env.sh`
# @desc     Sets the environment for developers
# @install  Put this file into the GO Workspace directory
#
# bash-$ ls workspace/go/
#  - set_env.sh*
#  - bin/
#  - src/
#  - tmp/
#  - pkg/
#
###

The Code :

#!/bin/bash

#Get the script's own directory instead of where it's being called from
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Set PATH
if [[ "$PATH" != ?(*:)"$DIR/bin"?(:*) ]]; then
  export PATH=$PATH:$DIR/bin
fi

# Set GOPATH - used by GO
if [[ -z "$GOPATH" ]]; then
  export GOPATH=$DIR
fi

1 Response
Add your response

setenv.sh: line 7: syntax error in conditional expression: unexpected token `('
set
env.sh: line 7: syntax error near ?(*' set_env.sh: line 7:if [[ "$PATH" != ?(:)"$DIR/bin"?(:) ]]; then'

over 1 year ago ·