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
+3.8k Golang : Reverse a string with unicode
+7.9k Golang : GUI with Qt and OpenCV to capture image from camera
+3.2k Golang : Handle Palindrome string with case sensitivity and unicode
+3.9k Golang : Load ASN1 encoded DSA public key PEM file example
+6.4k Golang : Read file and convert content to string
+2.1k PHP : See installed compiled-in-modules
+2.5k Unix/Linux : How to archive and compress entire directory ?
+6.5k CodeIgniter : Load different view for mobile devices
+4.7k Golang : How to determine a prime number?
+5.6k Golang : Listen and Serve on sub domain example
+6.3k Golang : Force download file example
+7.9k Golang : HTTP response JSON encoded data