Skip to content

Instantly share code, notes, and snippets.

@dev117uday
Created November 30, 2020 18:38
Show Gist options
  • Save dev117uday/bfbb5b1b83c37e6570d708220213b728 to your computer and use it in GitHub Desktop.
Save dev117uday/bfbb5b1b83c37e6570d708220213b728 to your computer and use it in GitHub Desktop.
Golang tooling

Golang tooling

Video : Go toolings

  • Formattor : gofmt main.go

    • to view diff use -d
  • to get all import inside a program : goimports

  • to compile for windows : GOOS=windows go build

  • to install a program : go install -> it installs it in GOPATH

Go List :

  • to list the path of package : go list
  • to print the name of the file : go list -f '{{ .Name }}'
  • to print the documentation of the program : go list -f '{{ .Doc }}'
  • to print all the imports : go list -f '{{ .Imports }}'
  • to get all packages that one of the package depends on : go list -f '{{ join .Imports "\n" }}' fmt
  • to get documentation for package : go doc fmt (using "fmt" as example)
  • to get doc for a function inside a package : go doc fmt Println (using "fmt" as package and "Println" as function)
  • to start documentation server : godoc -http :6060
  • to check for possible errors in program : go vet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment