Go - Commands

 
  • go - to see all the subcommands of Go used when developing and maintaining Go code
  • go env to display information about current Go environment
    • GOPATH -- defines root of your workspace and location of 3rd party source code, packages, and modules
    • GOROOT -- path where GO SDK is installed
  • go env GOROOT or go env <env_variable_name> - to know value of specific go env variable name
  • go help env  - display the documentation about the environment
  • go help environment  - display the documentation about the environment and about each variable
  • go doc <package_name> to know about standard documentation of a particular package
  • For E.g.,  go doc fmt (or) go doc math (or) go doc "gofmt"
  • go tool dist list  - display the full list of supported OS and architecture
  • go test  - to perform the unit test of the Go code
  • go get <module_name> - to get the module needed for our code
  • go list  -m all - display the
  • go mod  - to manage and maintain modules
  • go mod why -m <module_name> - to understand why a module is needed
  • go mod verify  - to verify the integrity of the downloaded modules by consulting "go.sum" which contains the cryptographic checksums of all downloaded modules
  • go list  -u -m all - display all the dependent modules and whether an updated version exists and what the latest semantic version is
  • go mod tidy - to prune out any required module declarations from the go mod file
  • gofmt or go fmt [-n] [-x] [packages] - to reformat source code as per Go's standard
  • go fmt [-s] [-d] [packages] - to reformat source code as per Go's standard
    • -s to simplify code after applying rewrite rule
    • -d to print the differences/diff
    • -w will save the changes 
  • go fmt [-s] [-d] . (single dot)- to reformat source code on all files in current directory
  • go fmt [-s] [-d] ./...  (triple dot - short cut wrapper) - to reformat source code on all files in project
  • go vet  - static analysis of source code
  • go tool dist list  - display the
  • gofmt
  • golint
  • go vet
  • go  --> will print help
  • go run hello.go

No comments:

Post a Comment