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
Written by Boopathi Rajaa
Related protips
1 Response
setenv.sh: line 7: syntax error in conditional expression: unexpected token `('
setenv.sh: line 7: syntax error near ?(*'
set_env.sh: line 7:
if [[ "$PATH" != ?(:)"$DIR/bin"?(:) ]]; then'
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Environment
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#