Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // To install go
- version=$(curl -s https://go.dev/dl/ | grep -oP 'go([0-9]+(\.[0-9]+)+)\.linux-amd64\.tar\.gz' | sort -rV | head -n 1 | grep -oP '[0-9]+\.[0-9]+\.[0-9]+')
- # rcVersion=$(curl -s https://go.dev/dl/ | grep -oP 'go[0-9]+\.[0-9]+rc[0-9]+\.linux-amd64\.tar\.gz' | sort -rV | head -n 1 | grep -oP -i '[0-9]+\.[0-9]+rc[0-9]+')
- # Download, unpack and install go
- wget https://go.dev/dl/go$version.linux-amd64.tar.gz
- gunzip go$version.linux-amd64.tar.gz
- tar xvf go$version.linux-amd64.tar
- mv go /usr/local
- ln -s /usr/local/go/bin/* /usr/bin
- rm -r go$version.linux-amd64.tar
- # Set envs
- export GOPATH=/usr/local/go
- export GOCACHE=/usr/local/go/cache
- # Re-Register go bins
- for bin in $(ls /usr/local/go/bin)
- do
- [ -f /usr/bin/$bin ] && rm -r /usr/bin/$bin
- [ ! -f /usr/bin/$bin ] && ln -s /usr/local/go/bin/$bin /usr/bin
- done
- # Check version, to see, if go installed
- go version
- # To register all binarys all go packages (new)
- for bin in $(ls /root/go/bin)
- do
- [ -f /usr/bin/$bin ] && rm -r /usr/bin/$bin
- ln -s /root/go/bin/$bin /usr/bin
- done
- // To uninstall go
- rm -r /usr/local/go
- rm -r /usr/bin/go*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement