46

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}.

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

1 Answers1

47

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.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
  • 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 – Sebastian Meier zu Biesen Mar 17 '21 at 00: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 '22 at 01:09