diff --git a/README.md b/README.md index 0d608ff..a835e4d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # go-install a curl/bash script to install the latest version of golang + +## usage + +tbd \ No newline at end of file diff --git a/go.env b/go.env new file mode 100644 index 0000000..585f762 --- /dev/null +++ b/go.env @@ -0,0 +1,4 @@ +export GOBIN=$HOME/.local/bin +export GOPATH=$HOME +export GOROOT=$HOME/go +export PATH=$GOROOT/bin:$GOBIN:/usr/local/go/bin:$PATH diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..f903a9e --- /dev/null +++ b/install.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Install Go +wget https://go.dev/dl/go1.25.1.linux-amd64.tar.gz +tar -xzf go1.25.1.linux-amd64.tar.gz +sudo rm -rf $HOME/go +mv go "$HOME" +rm go1.25.1.linux-amd64.tar.gz + +# Remove any existing Go-related exports from /etc/profile +# A backup will be created at /etc/profile.bak +sed -i.bak \ + -e '/export GOBIN/d' \ + -e '/export GOPATH/d' \ + -e '/export GOROOT/d' \ + $HOME/.bashrc + +# Append the desired Go environment variables +cat go.env || sudo tee $HOME/.bashrc +source go.env + +echo "run 'source ~/.bashrc' to activate the Go installation or close this terminal and open a new one" \ No newline at end of file