Skip to content

Go-Installer: Effortless Golang Installation with One Command! ๐Ÿš€

License

Notifications You must be signed in to change notification settings

faelmori/go-installer

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Go Installer ๐Ÿน

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

Contributions Welcome .github/workflows/test.yml

How to use it (Linux/MacOS) ๐Ÿค”

Installing (or even updating) Go โฌ‡๏ธ

You can clone the repository and then choose how you want to run the script:

git clone
cd go-installer
  • By running the script directly:

    • Linux: bash go.sh
    • MacOS: ./go.sh
    • Windows: .\go.ps1

Or by simply running whatever suits you from the following commands (wget 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 where Go will be installed. $HOME/go is the default workspace.

To install Go to another location or set a custom workspace, set the 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 latest 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

Checking if a specific version is installed ๐Ÿ”

You can check if a specific version of Go is installed by using the --version check flag, followed by the version you want to check.

bash go.sh --version check 1.19.4

Show Help Message ๐Ÿ

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

Uninstalling Go โŒ

bash go.sh remove

Running Tests Locally with Docker ๐Ÿณ

You can run tests locally using Docker to ensure a consistent environment and prevent side-effects on your host system. On CI environments, tests will run normally.

To run tests locally, simply use the make test command, and all the magic will happen:

make test

This command will build the Docker image and run the tests inside the Docker container.

How to use it (Windows) ๐Ÿค”

Installing (or even updating) Go โฌ‡๏ธ

.\go.ps1 -Command install

Specifying a version to install ๐Ÿง

.\go.ps1 -Command install -Version 1.19.2

Checking if a specific version is installed ๐Ÿ”

.\go.ps1 -Command remove

Uninstalling Go โŒ

.\go.ps1 -Command update

Show Help Message ๐Ÿ

.\go.ps1 -Command help

Running Tests Locally with Docker ๐Ÿณ

.\go.ps1 -Command test

Using Makefile for Common Tasks ๐Ÿ› ๏ธ

A Makefile is provided to simplify common tasks. Here are some useful commands:

  • Linux/MacOS

    • Install Go: make install
    • Uninstall Go: make uninstall
    • Check if a specific version is installed: make check-version VERSION=1.19.4
    • Run tests: make test
  • Windows

    • Install Go: make install-windows
    • Uninstall Go: make uninstall-windows
    • Check if a specific version is installed: make check-version-windows VERSION=1.19.4
    • Run tests: make test-windows

How to Contribute ๐Ÿค

  1. Fork the repository.
  2. Clone the forked repository.
  3. Create a new branch.
  4. Make your changes.
  5. Commit your changes.
  6. Push the changes to your fork.
  7. Create a pull request.
  8. Star the repository.
  9. Wait for the pull request to be reviewed and merged.
  10. Celebrate ๐ŸŽ‰

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.
  • Removes the downloaded installation file.
Demo.mp4

๐Ÿ”ฅ WORKS LIKE A CHARM ๐Ÿš€

About

Go-Installer: Effortless Golang Installation with One Command! ๐Ÿš€

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 60.8%
  • PowerShell 22.7%
  • Makefile 16.5%