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
+41.2k Golang : Convert string to array/slice
+10k Golang : Detect number of faces or vehicles in a photo
+9k Golang : does not implement flag.Value (missing Set method)
+54.8k Golang : Unmarshal JSON from http response
+37.7k Golang : Read a text file and replace certain words
+15.9k Golang : How to check if input from os.Args is integer?
+21.5k Golang : Convert string slice to struct and access with reflect example
+9.2k Golang : Web(Javascript) to server-side websocket example
+8.8k Golang : How to use Gorilla webtoolkit context package properly
+5.8k Golang : Grab news article text and use NLP to get each paragraph's sentences
+9.7k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+23.6k Golang : Use regular expression to validate domain name