36

As stated, I get that go install copies the executable to {GOPATH}/bin but is there such a thing as go uninstall?

After go clean, the executable is still in {GOPATH}/bin; I found nothing in the docs, bar a rather blunt force rm -f {filename}.

3
  • 4
    "is there such a thing as go uninstall?" -- No, there isn't.
    – mkopriva
    Mar 16, 2021 at 20:49
  • 3
    go install installs a single binary. To uninstall, just delete the binary.
    – Adrian
    Mar 16, 2021 at 21:15
  • 3
    Similar question for packages with go get from a few years ago: stackoverflow.com/questions/13792254/… StackOverflow used to be a kinder place.... Mar 16, 2021 at 23:19

1 Answer 1

38

Removing the installed executable with rm is the right way to go.

In Go, go install builds a single-file binary and "installs" it by copying it to the appropriate directory (*). To "uninstall" this binary, simply remove it with rm.

It may feel "blunt force" to you, but it's actually reassuring if you think about it. There's little magic involved. Installation means a single binary gets placed in some directory (which is likely in your $PATH).

See also this answer for a relevant discussion of removing packages installed with go get


(*) From go help install:

Executables are installed in the directory named by the GOBIN environment variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH environment variable is not set. Executables in $GOROOT are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN.

2
  • 2
    Thank you very much Eli, you are of course right, that the single executable is very re-assuring, compared to some of the crud attached to things like .NET etc, I was just really wanting to make sure that is the correct thing to do considering I want to use docker & CI/CD on my golang projects this actually simplifies things immensely Mar 17, 2021 at 0:05
  • For other users who found this answer non-straightforward, go installation (for Mac) is usually in /usr/local/go. Delete this go folder to completely uninstall.
    – Deborah
    Oct 11, 2022 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.