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
+5.7k Linux : Disable and enable IPv4 forwarding
+9.9k CodeIgniter : Load different view for mobile devices
+32.8k Golang : How to check if a date is within certain range?
+9.8k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral
+26.2k Golang : Get executable name behind process ID example
+15.1k nginx: [emerg] unknown directive "ssl"
+5.1k Responsive Google Adsense
+30.7k Golang : Interpolating or substituting variables in string examples
+28.3k Golang : Change a file last modified date and time
+12.2k Golang : Get month name from date example
+15k Golang : Save(pipe) HTTP response into a file
+12.3k Golang : Extract part of string with regular expression