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
+7k Golang : Multiplexer with net/http and map
+6.2k Golang : Gorrila mux.Vars() function example
+15.4k Golang : File path independent of Operating System
+18.6k Golang : Set or Add HTTP Request Headers
+9.8k Golang : Web routing/multiplex example
+15.5k Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
+5.8k Fix sudo yum hang problem with no output or error messages
+8.6k Javascript : Read/parse JSON data from HTTP response
+4.9k Golang : How to search a list of records or data structures
+16.3k Golang : [json: cannot unmarshal object into Go value of type]
+18.7k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+4.8k Unix/Linux : How to test user agents blocked successfully ?