Skip to content

Instantly share code, notes, and snippets.

@taking
Last active March 31, 2022 03:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taking/f4774c19f4a15704d143faf0ab4b5567 to your computer and use it in GitHub Desktop.
Save taking/f4774c19f4a15704d143faf0ab4b5567 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author by Taking
# (1) go language install + env
DL_PATH_URL="$(wget --no-check-certificate -qO- https://golang.org/dl/ | grep -oP '\/dl\/go([0-9\.]+)\.linux-amd64\.tar\.gz' | head -n 1)"
go_latest_ver="$(echo $DL_PATH_URL | grep -oP 'go[0-9\.]+' | grep -oP '[0-9\.]+' | head -c -2 )"
echo "go ver is $go_latest_ver"
if [ -d /usr/local/go ]; then
echo "${RED}--go exist.. PASS--${NC}"
else
echo "${RED}--go downloading...--${NC}"
cd ~/
wget --no-check-certificate --continue --show-progress https://golang.org/dl/go${go_latest_ver}.linux-amd64.tar.gz
tar -xzf go${go_latest_ver}.linux-amd64.tar.gz
sudo mv go /usr/local
rm ~/go${go_latest_ver}.linux-amd64.tar.gz
PROFILE_PATH="$HOME/.profile"
STRING="$( cat "$PROFILE_PATH" )"
if [[ $STRING =~ "/usr/local/go" ]]; then
echo 'go installed'
else
cat <<'EOF' >> $HOME/.bashrc
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
EOF
source $HOME/.bashrc
go version
fi
fi
source $HOME/.profile
apt-get install build-essential -y
@taking
Copy link
Author

taking commented Jun 7, 2021

how-to

wget  https://gist.githubusercontent.com/taking/f4774c19f4a15704d143faf0ab4b5567/raw/eef2c862bebfe46bec196791abc8be283ae36de8/latest-go-lang-ubuntu
chmod a+x latest-go-lang-ubuntu
./latest-go-lang-ubuntu

+++
sh latest-go-lang-ubuntu 하면 에러남

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment