DEV Community

loading...
Cover image for Check if go package installed + "uninstall go package"

Check if go package installed + "uninstall go package"

#go
hzoltan
this is a place for the breadcrumbs of my learning path
Updated on ・1 min read

In a directory where there is a go.mod file, you can discover the install path:

$ go list -f '{{.Target}}'
Enter fullscreen mode Exit fullscreen mode

I don't come up with this, just found it at https://golang.org/doc/tutorial/compile-install .

One liner:

$ go list -f '{{.Target}}' | if xargs ls -la &> /dev/null ; then echo "Installed"; else echo "Not installed"; fi
// Outputs "Installed" or "Not installed"
Enter fullscreen mode Exit fullscreen mode

Remove it:

$ go clean -i
Enter fullscreen mode Exit fullscreen mode

Discussion (0)