/go-installer

Go-Installer: Effortless Golang Installation with One Command! 🚀

Primary LanguageShellMIT LicenseMIT

Go Installer 🐹

Install Golang on Linux or Mac with hassle of environment variables setting.

Contributions Welcome .github/workflows/test.yml

How to use it 🤔

Installing (or even updating) Go ⬇️

You can clone the repository then run bash go.sh.

Or by simply running whatever suits you from the following commands (wget1 or curl):

# downloads then runs the script
wget https://git.io/go-installer.sh && bash go-installer.sh
# doesn't download the script ~ runs the script directly 
bash <(curl -sL https://git.io/go-installer)

Now, you can go grab a cup of coffee ☕, sit back 😌 and relax while the magic happens! 🔮

Note
By default the script will create .go and go folders on your HOME directory & add the needed variables to your PATH variable.

$HOME/.go is the location where Go will be installed to. $HOME/go is the default workspace.

In order to install Go to other location or set custom workspace. You can set environment variables GOROOT or GOPATH before installing (or uninstalling) Go.

For example:

export GOROOT=/opt/go            # where Go is installed
export GOPATH=$HOME/projects/go  # your workspace

Read more about workspaces in Go.

Specifying a version to install 🧐

By default the script installs the lastest version available.
You can choose what version to install by adding the --version flag, followed by the version you want to install.

bash go.sh --version 1.19.4

Show Help Message 🍁

To show the following help message use bash go.sh help.

Uninstalling Go ❌

bash go.sh remove

How it works ⚙️

The script does the following steps:

  • Checks if Go is already installed.
  • Detects the installed operating system (Linux or Mac).
  • Detects system architecture (armv6, armv8, amd64, i386).
  • Parses the https://go.dev/dl download page to find the latest version of Go that is available for your platform and architecture.
  • Exits if you have the latest version of Go already installed.
  • Downloads the latest version of Go.
  • Creates the needed directories for workspace and Go binaries.
  • Extracts the files of the downloaded package.
  • Adds the binaries to PATH environment variable.
Demo.mp4

🔥 WORKS LIKE A CHARM 🚀

Footnotes

  1. the script depends on wget (1, 2)