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
+8.8k Golang : Heap sort example
+10.7k Golang : How to delete element(data) from map ?
+14.8k Golang : Send email with attachment(RFC2822) using Gmail API example
+9.5k Golang : Terminate-stay-resident or daemonize your program?
+4.7k JavaScript : Rounding number to decimal formats to display currency
+6.9k Golang : Pat multiplexer routing example
+9.3k Golang : How to control fmt or log print format?
+5.1k Golang : micron to centimeter example
+9k Golang : What is the default port number for connecting to MySQL/MariaDB database ?
+13.9k Golang : Gin framework accept query string by post request example
+5k Python : Find out the variable type and determine the type with simple test
+37.6k Upload multiple files with Go