Add initial Go installation script and setup files

This commit is contained in:
2025-10-05 10:25:45 +01:00
parent bfe757ea32
commit c3c875791b
3 changed files with 31 additions and 0 deletions

View File

@@ -1,2 +1,6 @@
# go-install
a curl/bash script to install the latest version of golang
## usage
tbd

4
go.env Normal file
View File

@@ -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

23
install.sh Executable file
View File

@@ -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"