keepcalculator

06 Numbers and Powers

Uninstall Go macOS: Complete Removal Guide

Card No. 06·72320 · Updated · Standard formula, shown below

If you need to completely remove the Go programming language from your Mac, the process involves deleting the Go directory, cleaning up your shell configuration files, and removing any leftover cache and environment variables. This guide covers the standard uninstall steps for both Intel and Apple Silicon Macs, including how to verify the removal is complete.

What Go Installs on Your Mac

Go, also known as Golang, is a compiled programming language developed by Google. When you install Go on macOS, it typically places the core files in /usr/local/go (the “Go root”). This directory contains the compiler, standard library, and other tools. Your own projects and downloaded packages are stored separately in your home directory under go (the “Go path”), usually at ~/go. The installation also modifies your shell profile files to add Go’s binary directory to your system’s PATH, which is what allows you to run go commands from anywhere in the terminal.

Before You Start: Back Up Your Work

Uninstalling Go will not delete your source code files, but it will remove the Go toolchain and all downloaded third-party packages. If you have any projects that rely on specific package versions, consider backing up your ~/go/pkg/mod directory or your entire ~/go folder to an external drive. Also, note any custom environment variables you’ve set in your shell profile, as you’ll need to remove them manually.

Step-by-Step Uninstall Process

Follow these steps in order. The commands are safe to run, but double-check each one before executing.

1. Remove the Go Root Directory

Open Terminal and run the following command to delete the main Go installation:

sudo rm -rf /usr/local/go

You’ll be prompted for your administrator password. This removes the compiler, tools, and standard library. If you installed Go using a package manager like Homebrew, you might have a different location. For Homebrew, use brew uninstall go instead, which handles the removal automatically.

2. Clean Up Your Shell Profile

Go’s installer adds a line to your shell configuration file to update your PATH. Depending on your default shell, this is either ~/.zshrc (for zsh, the default since macOS Catalina) or ~/.bash_profile (for bash). Open the file with a text editor:

nano ~/.zshrc

Look for a line that contains /usr/local/go/bin and remove it. It might look like this:

export PATH=$PATH:/usr/local/go/bin

Save the file (Ctrl+O, then Enter, then Ctrl+X in nano) and close it. If you also added Go’s path to your ~/.bash_profile, repeat the process there.

3. Remove the Go Path Directory

Your personal Go workspace, where downloaded packages and compiled binaries live, is usually in your home directory. Delete it with:

rm -rf ~/go

If you’ve set a custom GOPATH in your environment variables, remove that directory instead. Be careful: this deletes all your downloaded dependencies and any binaries you’ve installed with go install.

4. Clear Go’s Cache and Temporary Files

Go stores build caches and other temporary data in a few places. Remove them to free up space and ensure no leftover files interfere with a future reinstall:

rm -rf ~/Library/Caches/go-build
rm -rf ~/Library/Application Support/go

These commands delete the build cache and application support files. They are safe to remove and will be recreated if you install Go again.

5. Verify the Removal

After completing the steps above, close and reopen Terminal (or run source ~/.zshrc) to refresh your shell. Then check if Go is still accessible:

go version

If you see a message like command not found: go, the uninstall was successful. You can also check the Go root directory to confirm it’s gone:

ls /usr/local/go

If you get a “No such file or directory” error, everything is clean.

Common Issues and Troubleshooting

Sometimes the uninstall doesn’t fully work. Here are the most frequent problems and their fixes:

  • “go” command still works after removing /usr/local/go: This usually means another Go installation exists, perhaps via Homebrew or a separate download. Run which go to see the path. If it points to /opt/homebrew/bin/go, use brew uninstall go.
  • PATH still contains Go after editing .zshrc: Your shell might be reading from a different file, like ~/.profile or ~/.bashrc. Check all of them for Go references.
  • Permission errors when deleting /usr/local/go: The sudo command should handle this. If you still get errors, ensure no Go processes are running with pgrep go, then try again.
  • Leftover Go processes: If you have a Go server or a compiled binary running, it won’t be affected by the uninstall. You’ll need to stop it manually with killall <process-name>.

How to Reinstall Go Later

If you need Go again, the official installer from go.dev is the most straightforward method. Download the macOS package, run it, and it will recreate the /usr/local/go directory and update your shell profile automatically. Alternatively, if you prefer Homebrew, a simple brew install go will set everything up. After reinstalling, remember to re-download your project dependencies with go mod download.

Frequently Asked Questions

Does uninstalling Go delete my code?

No. Your source code files (like .go files) are not touched by the uninstall process. Only the Go toolchain, the ~/go directory (which contains dependencies and compiled binaries), and cache files are removed. Your projects remain safe on disk.

What’s the difference between /usr/local/go and ~/go?

/usr/local/go is the Go root – the installation directory containing the compiler and standard library. ~/go is your Go path – the workspace where Go stores downloaded packages (in pkg/mod) and binaries you install with go install. You need to delete both to fully uninstall.

Is there an official uninstaller for Go on macOS?

No, the Go team does not provide an official uninstaller. The manual removal steps described above are the standard method recommended by the community and the official documentation. It’s a simple process because Go keeps its files in predictable locations.

Will uninstalling Go affect my other development tools?

No. Go is independent of other languages and tools like Python, Node.js, or Xcode. Removing Go will not affect them. However, if you have scripts or build tools that call the go command, they will stop working until you reinstall Go.

How do I remove Go if I installed it with Homebrew?

If you used Homebrew, the command is simply brew uninstall go. This removes the binary and its dependencies. You might also want to run brew autoremove to clean up any now-unused packages. The Homebrew method doesn’t touch your ~/go directory, so you’ll still need to delete that manually if you want a complete removal.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →