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.1k Golang : Return multiple values from function
+17.3k How to enable MariaDB/MySQL logs ?
+6k Golang : Calculate US Dollar Index (DXY)
+5.5k Swift : Get substring with rangeOfString() function example
+12.8k Swift : Convert (cast) Int to String ?
+6.3k PHP : Shuffle to display different content or advertisement
+21.3k SSL : How to check if current certificate is sha1 or sha2
+3.9k Javascript : Empty an array example
+13.5k Golang : Check if an integer is negative or positive
+5.8k Golang : Build new URL for named or registered route with Gorilla webtoolkit example
+25.5k Golang : missing Mercurial command
+6.4k Golang : How to validate ISBN?