If I understand correctly, go install
puts binaries in $GOBIN
directory.
I tend to forget which packages provide which binaries in $GOBIN
and which packages I go install
-ed.
Is there a way to list packages that are currently go install
-ed?
I could, obviously, do ls $GOBIN
and that'll give me names of binaries. However, I'm looking for a way to get a list of packages with their long names, e.g. github.com/operator-framework/operator-sdk
.
Update: go list ...
(suggested here) does not seem to apply to my case because this command expects me to be in a directory containing go.mod
file. I understand that go list
is designated for listing packages of a project. In my case, I need to find out all packages that are installed into $GOBIN
of my system/user.
Much like the previous behaviour of go get , go install places binaries in $GOPATH/bin , or in $GOBIN if set. See the “Setting up your PATH “ section in Installing Go to ensure your PATH is set correctly.
To list packages in your workspace, go to your workspace folder and run this command: go list ./... ./ tells to start from the current folder, ... tells to go down recursively.
All downloaded modules are cached locally in your $GOPATH/pkg/mod directory by default. If you import a package to your project without downloading it first using go get , the latest tagged version of the module providing that package will be installed automatically and added to your go.
Go The Go Command Go Getgo get downloads the packages named by the import paths, along with their dependencies. It then installs the named packages, like 'go install'. Get also accepts build flags to control the installation. When checking out a new package, get creates the target directory $GOPATH/src/<import-path> .
List installed packages in Debian, Ubuntu using apt command Apt provides a high-level command line interface for the package management system in Debian, Ubuntu and other Debian-based systems. To display the list of installed packages in Debian, Ubuntu, Linux Mint and other DEB-based systems, run: $ apt list --installed
Dpkg is a command line tool to install, build, remove and manage Debian packages. To list all installed packages with versions and details using dpkg command, run: Alternatively, you can use dpkg-query command to list all installed Debian packages.
You can list all pip-installed packages by running the following command: pip freeze The output is a list of packages and their versions installed in the current environment.
For a complete list of all packages and dependencies (including OS-level and transitive dependencies, as well as shared libraries), you can use the Web GUI, which provides a full Bill of Materials view. Give it a try by signing up for a free ActiveState Platform account.
For each binary in $GOBIN
, you can use go version -m
to show information about the version of Go and the module versions that were used to build that binary. For example, here's go version -m ~/go/bin/goimports
for me.
$ go version -m ~/go/bin/goimports
/Users/jayconrod/go/bin/goimports: go1.15.2
path golang.org/x/tools/cmd/goimports
mod golang.org/x/tools v0.0.0-20200910165216-53e29e9d1252 h1:qn28WK3EvdJOSlyZFNeWnaEX8X5GiQv+8mrw9mYrXko=
dep golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
dep golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
The path
line shows the name of the main
package that was installed. Looks like I need to update it.
$ go install golang.org/x/tools/cmd/goimports@latest
$ go version -m ~/go/bin/goimports
/Users/jayconrod/go/bin/goimports: go1.17rc1
path golang.org/x/tools/cmd/goimports
mod golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
dep golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
dep golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
dep golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With