Last active
March 31, 2022 03:14
-
-
Save taking/f4774c19f4a15704d143faf0ab4b5567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how-to
+++
sh latest-go-lang-ubuntu 하면 에러남