Execute project
go run .
Create an executable file of the project (build)
go build .
Download and install external package
go get {package path}
#### eg.
go get gorm.io/gorm
Display Current GOPATH
go env GOPATH
install new go package
go install test-app
Update package
go get -u test-app
List Packages Alongside Dependencies
go list
go list ./...
Display Version Information
go version
Maintain Module Dependencies
The go mod tidy command allows us to add missing dependencies or delete unused modules. This go command helps in maintaining module dependencies and keep your applications as lean as possible. Simply run the following simple command to do this.
Make sure to run this from your project’s root directory. You can check the go.mod file to see which dependencies were added or deleted. The -v flag, if used, causes tidy to display which modules were removed to the standard error.
go mod tidy [-v]
Verify Module Dependencies
go mod verify
Display Why Packages/Modules are Needed
You can see why certain modules or packages are required in your application. This is useful if you are working with someone else’s code or are trying to figure out what certain things do in a specific project. The “why” command of the mod tool allows us to do this
The first one is the general syntax, and the second one is an example. It prints out why the language and encoding packages are required in your application.
go mod why [-m] [-vendor] packages...
go mod why golang.org/x/text/language golang.org/x/text/encoding