...
1if [ -z $1 ]; then
2 echo "Please input outputfile"
3 exit 1
4fi
5echo $1
6
7outputFile=$1
8
9if [ "$2" ]; then
10 echo $2
11 outputFile=$2
12fi
13
14set -x
15set -e
16outputFile="$(realpath $outputFile)"
17echo "output json file: $outputFile"
18
19TMPDIR="/tmp"
20if [ ! "$(go version | awk '{print $3}' | cut -c 3-6)" = "1.18" ]
21then
22 wget https://golang.org/dl/go1.18.linux-amd64.tar.gz
23 tar -C $TMPDIR -xzf go1.18.linux-amd64.tar.gz
24 export GOROOT=$TMPDIR/go
25 export PATH=$GOROOT/bin:$PATH
26fi
27
28DIRECTORY=$(cd `dirname $0` && pwd)
29
30if [ "$GOPATH" = "" ]; then
31 WORKFOLDER="$(realpath $DIRECTORY/../../../)"
32 echo $WORKFOLDER
33 export GOPATH=$WORKFOLDER/gofolder
34fi
35
36if [ ! -d "$GOPATH/bin" ]; then
37 echo "create gopath folder"
38 mkdir -p $GOPATH/bin
39fi
40echo $GOPATH
41
42export GO111MODULE=on
43
44generatorDirectory="$(realpath $DIRECTORY/../tools/generator)"
45cd $generatorDirectory
46go build
47
48cp generator $GOPATH/bin/
49export PATH=$GOPATH/bin:$PATH
50cd $DIRECTORY
51
52if [ ! -L "$GOPATH/bin/pwsh.exe" ]; then
53 ln -s /usr/bin/pwsh $GOPATH/bin/pwsh.exe
54fi
55
56cat > $outputFile << EOF
57{
58 "envs": {
59 "PATH": "$GOPATH:$PATH",
60 "GOPATH": "$GOPATH",
61 "GOROOT": "$GOROOT"
62 }
63}
64EOF
View as plain text