-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc_golang
44 lines (34 loc) · 1.23 KB
/
.bashrc_golang
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#----- header -----
[ "${0##*/}" != "${BASH_SOURCE##*/}" ] || { >&2 echo -e "ERROR\tfile must be sourced ($0)"; return 2; }
# prevent multiple-inclusion
__link=`readlink -f "$BASH_SOURCE"`
declare -n __tag=SOURCE_${__link//[^a-zA-Z0-9_]/}
[ ${__tag:-0} -eq 0 ] || return 0
__tag=1
#------------------
return 0 # disabled
# ${GOROOT:-'go{,lang}{-,}'$GO_VERSION
source ${BASH_SOURCE%_*}/_3rdparty go
#FIXME detect if Windows binary. if so, we can't mangle paths into UNIX-style
#https://golang.org/cmd/go/#hdr-GOPATH_environment_variable
: ${GOROOT:=`go env GOROOT`}
# Windows: %USERPROFILE%/go
# Unix: $HOME/go
# Personally I prefer %LOCALAPPDATA%/go and $HOME/.go
IFS=':' read -a items < <(convert_path `go env GOPATH`)
for d in "${items[@]}"; do
mkdir -p "$d"
done
# if `is_windows go` then mkdir "$LOCALAPPDATA/go" and GOPATH=`convert_path -t windows -E ...`
# walk elements of GOPATH and add to $PATH
# cygpath -p $GOPATH
#IFS="${PATHSEP:?}"
#for v in GOPATH; do
# addPath "$v/bin"
#done
#unset IFS
#TODO Windows 'go get' doesn't work if using Cygwin 'git'
# if OSTYPE=cygwin or uname -k = windows, then git version | grep windows or issue WARN
#[[ "${OSTYPE:-`uname -o`}" = [cC]ygwin ]]
export ${!GO*}
# vim: expandtab:ts=4:sw=4