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
+11.7k Golang : Google Drive API upload and rename example
+3.9k Golang : Intercept, inject and replay HTTP traffics from web server
+5.3k Golang : A simple forex opportunities scanner
+7.5k Golang : Format strings to SEO friendly URL example
+16.2k Golang : Determine if directory is empty with os.File.Readdir() function
+7.4k Golang : Populate slice with sequential integers example
+4.2k Javascript : How to replace HTML inside <div>?
+5.4k Golang : Normalize email to prevent multiple signups example
+3.7k PHP : Fix Call to undefined function curl_init() error
+4.2k Swift : Get substring with rangeOfString() function example
+5.4k Golang : Fibonacci number generator examples
+10.5k Golang : ROT47 (Caesar cipher by 47 characters) example