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
+18k Mac OSX : Homebrew and Golang
+9.8k Android Studio : Create custom icons for your application example
+4k Golang : Convert lines of string into list for delete and insert operation
+18.1k Golang : Count JSON objects and convert to slice/array
+11.5k Golang : Pass database connection to function called from another package and HTTP Handler
+5.2k Golang : Handling image beyond OpenCV video capture boundary
+12.7k Golang: Pad right or print ending(suffix) zero or spaces in fmt.Printf example
+4.4k PHP : Hide PHP version information from curl
+7k Golang : Find relative luminance or color brightness
+6.6k Golang : Ways to recover memory during run time.
+13k Golang : Recombine chunked files example
+12.5k Golang : Fix image: unknown format error