Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Last active June 7, 2021 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelCurrin/ca6b3b955172ff993184d39807dd68d4 to your computer and use it in GitHub Desktop.
Save MichaelCurrin/ca6b3b955172ff993184d39807dd68d4 to your computer and use it in GitHub Desktop.
Install Go with a package manager

Install Go with a package manager

If you want a manual solution instead for more control and to get the latest release available, see this gist.

Install the Go binary.

  • Debian/Ubuntu
    • Install with apt-get to /usr/bin/go. NB. Requires root privileges.
      $ sudo apt-get update
      $ sudo apt-get install golang-go
  • macOS
    • Install with Brew.
      $ brew install go

Set up Go packages.

  • Your user-level packages installed to Go bin (~/go/bin) must be available to execute. So add this to your profile config (.bash_profile or .profile).
    export PATH="$HOME/go/bin:$PATH"

Test your installation:

  • Version.
    $ go version
    go version go1.15.2 darwin/amd64
    
  • Check environment variables.
    $ go env
    GO111MODULE=""
    GOARCH="amd64"
    GOBIN=""
    GOCACHE="/Users/mcurrin/Library/Caches/go-build"
    GOENV="/Users/mcurrin/Library/Application Support/go/env"
    ...

For more info, see Install guide in the Go docs.

⚠️ Warning - if you install using a package manager, be sure to also upgrade using a package manager too. If you install version X using a package manager, then use Go itself to upgrade to Y, the old version of X will be replaced but your package manager will still think that version X is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment