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
+13.3k Golang : Convert(cast) int to int64
+20.5k Swift : Convert (cast) Int to int32 or Uint32
+9.8k Golang : Load ASN1 encoded DSA public key PEM file example
+7.8k Gogland : Where to put source code files in package directory for rookie
+12.2k Golang : Save webcamera frames to video file
+22.8k Golang : Strings to lowercase and uppercase example
+32.6k Golang : Copy directory - including sub-directories and files
+7.5k Linux : How to fix Brother HL-1110 printing blank page problem
+7.8k Golang : Generate human readable password
+6.4k Golang : Detect face in uploaded photo like GPlus
+12.9k Swift : Convert (cast) Int or int32 value to CGFloat
+11.4k Golang : Post data with url.Values{}