Skip to content

Instantly share code, notes, and snippets.

@rajeevsingh-ag
Created May 25, 2020 04:32
Show Gist options
  • Save rajeevsingh-ag/5f57528d2e26bf2028ddc540bbb06286 to your computer and use it in GitHub Desktop.
Save rajeevsingh-ag/5f57528d2e26bf2028ddc540bbb06286 to your computer and use it in GitHub Desktop.
#!/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