-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo-tasks.sh
executable file
·71 lines (59 loc) · 1.5 KB
/
go-tasks.sh
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# managing project only goenvs
goenv_on(){
if [ $# -eq 0 ]; then
_GOPATH_VALUE="${PWD}/.goenv"
else
cd $1 ; _GOPATH_VALUE="${PWD}/.goenv" ; cd -
fi
if [ ! -d $_GOPATH_VALUE ]; then
mkdir -p "${_GOPATH_VALUE}/site"
fi
export _OLD_GOPATH=$GOPATH
export _OLD_PATH=$PATH
export GOPATH=$_GOPATH_VALUE/site
export PATH=$PATH:$GOPATH/bin
}
alias goenv_off="export GOPATH=$_OLD_GOPATH ; export PATH=$_OLD_PATH ; unset _OLD_PATH ; unset _OLD_GOPATH"
# managing go deps
go_get_pkg(){
if [ $# -eq 0 ]; then
if [ -f "$PWD/go-get-pkg.txt" ]; then
PKG_LISTS="$PWD/go-get-pkg.txt"
else
touch "$PWD/go-get-pkg.txt"
echo "Created GoLang Package empty list $PWD/go-get-pkg.txt"
echo "Start adding package paths as separate lines." && return 0
fi
else
PKG_LISTS=($@)
fi
for pkg_list in $PKG_LISTS; do
cat $pkg_list | while read pkg_path; do
echo "fetching golag package: go get ${pkg_path}";
echo $pkg_path | xargs go get
done
done
}
_OLD_PWD=$PWD
cd $(dirname $0)
goenv_on
if [[ $# -ne 1 ]]; then
echo "Use it wisely..."
echo "Install tall Go lib dependencies: '$0 deps'"
echo "Run all Tests: '$0 test'"
exit 1
elif [[ "$1" == "deps" ]]; then
go_get_pkg
elif [[ "$1" == "test" ]]; then
go test ./...
elif [[ "$1" == "bin" ]]; then
bash $0 deps
mkdir -p ./bin
cd ./bin
for go_code_to_build in `ls ../axe_n0de_*.go`; do
echo "Building: "$go_code_to_build
go build $go_code_to_build
done
fi
cd $_OLD_PWD