Reputation: 949
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}
.
Upvotes: 81
Views: 50941
Reputation: 3167
If the removed bin file keeps coming back, you might be using a version manager.
Let's say you're using mise
version manager. In that case just removing the ~/.local/share/mise/shims/some-bin
will not be enough. The removed bin file will come back on each reshim
action. You also need to remove the ~/.local/share/mise/installs/go/{go_version}/bin/some-bin
file.
This probably applies for other version managers such as asdf, gvm, goenv etc.
Upvotes: 1
Reputation: 273706
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.
Upvotes: 84