Golang : List all packages and search for certain package
Problem :
You need to find out if a server has the packages that you need to run or compile your Golang source code. What are the tools available to do that?
Solution :
Use go list
command and pipe the output to grep
.
For example, to find out if the gorilla mux package is already imported or not.
go list ... | grep mux
Executing go list ...
will list all packages and pipe the output to grep to check if mux is listed.
IF not, execute go get github.com/gorilla/mux
and repeat go list ... | grep mux
again.
Reference :
http://stackoverflow.com/questions/28166249/how-to-list-installed-go-packages
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+11.3k Golang : How to use if, eq and print properly in html template
+29.7k Golang : Record voice(audio) from microphone to .WAV file
+22.2k Golang : Securing password with salt
+5.2k Golang : PGX CopyFrom to insert rows into Postgres database
+12.6k Golang : Transform comma separated string to slice example
+17.4k Golang : Multi threading or run two processes or more example
+8.5k Android Studio : Import third-party library or package into Gradle Scripts
+6.8k Mac/Linux/Windows : Get CPU information from command line
+5.8k Golang : List all packages and search for certain package
+41.4k Golang : Convert string to array/slice
+6.5k Golang : Map within a map example
+14.1k Golang : Fix image: unknown format error