Created
May 25, 2020 04:32
-
-
Save rajeevsingh-ag/5f57528d2e26bf2028ddc540bbb06286 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 | |
function checkGoInstalled() | |
{ | |
gobinfile="/usr/local/go/bin/go" | |
if test -f $gobinfile; then | |
echo "go binary exists - OK" | |
$gobinfile version | |
return 0 | |
else | |
echo "$gobinfile does not exist. Please install Go first - FAIL" | |
return -1 | |
fi | |
} | |
function updateBashRC() | |
{ | |
cat >>$HOME/.bashrc <<'BASHRCEDIT' | |
# Golang env | |
export GOROOT=/usr/local/go | |
export PATH=$GOROOT/bin/go:$PATH | |
BASHRCEDIT | |
echo "Updated $HOME/.bashrc" | |
} | |
# Main | |
checkGoInstalled | |
if test $? == 0; then | |
updateBashRC | |
else | |
echo "Exiting..." | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment