Forrest logo
tool overview
On this page you find all important commands for the CLI tool go. If the command you are looking for is missing please ask our AI.

go

Go is a statically typed and compiled programming language that was developed at Google in 2007. It was designed to be efficient, reliable, and easy to use. One of the key strengths of Go is its simplicity and readability, achieved by having a minimalistic syntax and a small standard library.

Go is commonly used for system programming, networking, web development, and building concurrent applications. It provides built-in support for concurrent programming through goroutines and channels, making it easier to write efficient and scalable programs.

The Go command line tool is an essential component of the Go programming language. It provides various commands to build, test, and manage Go programs. Some of the main features of the Go command line tool include:

  1. Building: It allows you to compile Go programs into executable binaries. You can specify various build options, such as output file name, target architecture, and optimization flags.

  2. Testing: It provides a convenient way to run unit tests for Go programs. By following certain conventions, you can easily write test functions and use the "go test" command to execute them.

  3. Dependency management: The Go command line tool has built-in support for managing dependencies. The "go get" command enables you to download and install external packages from the Go module repository.

  4. Formatting: It includes a command called "go fmt" that automatically formats Go source code according to a standardized style. This ensures consistent and readable code across different projects.

  5. Documentation: Go encourages good documentation practices, and the Go command line tool provides utilities to generate code documentation using the "go doc" command. It extracts package and function information from source code comments.

Overall, the Go command line tool simplifies the development and management of Go programs, providing a robust and efficient workflow for programmers.

List of commands for go:

  • go-bug:tldr:0a6ef go-bug: Open a web page to start a bug report.
    $ go bug
    try on your machine
    explain this command
  • go-build:tldr:2feec go-build: Compile a 'package main' file (output will be the filename without extension).
    $ go build ${path-to-main-go}
    try on your machine
    explain this command
  • go-build:tldr:f62b7 go-build: Compile, specifying the output filename.
    $ go build -o ${path-to-binary} ${path-to-source-go}
    try on your machine
    explain this command
  • go-build:tldr:fe1db go-build: Compile a main package into an executable, enabling data race detection.
    $ go build -race -o ${path-to-executable} ${path-to-main-package}
    try on your machine
    explain this command
  • go-clean:tldr:67267 go-clean: Delete all cached test results.
    $ go clean -testcache
    try on your machine
    explain this command
  • go-clean:tldr:73dab go-clean: Delete the build cache.
    $ go clean -cache
    try on your machine
    explain this command
  • go-clean:tldr:9191a go-clean: Delete the module cache.
    $ go clean -modcache
    try on your machine
    explain this command
  • go-clean:tldr:d7b1b go-clean: Print the remove commands instead of actually removing anything.
    $ go clean -n
    try on your machine
    explain this command
  • go-doc:tldr:606ca go-doc: Show package documentation and exported symbols.
    $ go doc ${encoding-json}
    try on your machine
    explain this command
  • go-doc:tldr:97daf go-doc: Show documentation for the current package.
    $ go doc
    try on your machine
    explain this command
  • go-doc:tldr:cdbe0 go-doc: Show also sources.
    $ go doc -all -src ${encoding-json}
    try on your machine
    explain this command
  • go-doc:tldr:f6566 go-doc: Show also documentation of symbols.
    $ go doc -all ${encoding-json}
    try on your machine
    explain this command
  • go-env:tldr:27177 go-env: Show all environment variables.
    $ go env
    try on your machine
    explain this command
  • go-env:tldr:42213 go-env: Reset an environment variable's value.
    $ go env -u ${GOBIN}
    try on your machine
    explain this command
  • go-env:tldr:5d848 go-env: Set an environment variable to a value.
    $ go env -w ${GOBIN}=${path-to-directory}
    try on your machine
    explain this command
  • go-env:tldr:a88e1 go-env: Show a specific environment variable.
    $ go env ${GOPATH}
    try on your machine
    explain this command
  • go-fix:tldr:932e1 go-fix: Update packages to use new APIs.
    $ go fix ${packages}
    try on your machine
    explain this command
  • go-fmt:tldr:67f62 go-fmt: Print which format commands are run as they are run.
    $ go fmt -x
    try on your machine
    explain this command
  • go-fmt:tldr:75e66 go-fmt: Format a specific Go package in your import path (`$GOPATH/src`).
    $ go fmt ${path-to-package}
    try on your machine
    explain this command
  • go-fmt:tldr:81b42 go-fmt: Print what format commands would've been run, without modifying anything.
    $ go fmt -n
    try on your machine
    explain this command
  • go-fmt:tldr:9c885 go-fmt: Format Go source files in the current directory.
    $ go fmt
    try on your machine
    explain this command
  • go-generate:tldr:464a5 go-generate: Generate Go files by running commands within source files.
    $ go generate
    try on your machine
    explain this command
  • go-get:tldr:43580 go-get: Modify the package with a given version in module-aware mode.
    $ go get ${example-com-pkg}@${v1-2-3}
    try on your machine
    explain this command
  • go-get:tldr:74c0d go-get: Add a specified package to `go.mod` in module-mode or install the package in GOPATH-mode.
    $ go get ${example-com-pkg}
    try on your machine
    explain this command
  • go-install:tldr:75cdc go-install: Compile and install the current package.
    $ go install
    try on your machine
    explain this command
  • go-install:tldr:b2056 go-install: Compile and install a specific local package.
    $ go install ${path-to-package}
    try on your machine
    explain this command
  • go-install:tldr:bf66a go-install: Install the latest version of a program, ignoring `go.mod` in the current directory.
    $ go install ${golang-org-x-tools-gopls}@${latest}
    try on your machine
    explain this command
  • go-list:tldr:515cc go-list: List packages in JSON format.
    $ go list -json time net/http
    try on your machine
    explain this command
  • go-list:tldr:72584 go-list: List standard packages.
    $ go list std
    try on your machine
    explain this command
  • go-list:tldr:a3cc8 go-list: List module dependencies and available updates.
    $ go list -m -u all
    try on your machine
    explain this command
  • go-list:tldr:f95e7 go-list: List packages.
    $ go list ./...
    try on your machine
    explain this command
  • go-mod:tldr:81345 go-mod: Download modules to local cache.
    $ go mod download
    try on your machine
    explain this command
  • go-mod:tldr:92404 go-mod: Add missing and remove unused modules.
    $ go mod tidy
    try on your machine
    explain this command
  • go-mod:tldr:ab3b9 go-mod: Copy sources of all dependencies into the vendor directory.
    $ go mod vendor
    try on your machine
    explain this command
  • go-mod:tldr:c6b84 go-mod: Initialize new module in current directory.
    $ go mod init ${moduleName}
    try on your machine
    explain this command
  • go-mod:tldr:c810b go-mod: Verify dependencies have expected content.
    $ go mod verify
    try on your machine
    explain this command
  • go-run:tldr:71f42 go-run: Run a Go file.
    $ go run ${filename-go}
    try on your machine
    explain this command
  • go-test:tldr:63cc8 go-test: [v]erbosely test the package in the current directory.
    $ go test -v
    try on your machine
    explain this command
  • go-test:tldr:95c27 go-test: Test the package found in the current directory.
    $ go test
    try on your machine
    explain this command
  • go-test:tldr:b4e46 go-test: Test the packages in the current directory and all subdirectories (note the `...`).
    $ go test -v ./...
    try on your machine
    explain this command
  • go-test:tldr:b806b go-test: Test the package in the current directory and run all benchmarks for 50 seconds.
    $ go test -v -bench . -benchtime ${50s}
    try on your machine
    explain this command
  • go-test:tldr:bd5f1 go-test: Test the package with coverage analysis.
    $ go test -cover
    try on your machine
    explain this command
  • go-test:tldr:c2130 go-test: Test the package in the current directory and run all benchmarks.
    $ go test -v -bench .
    try on your machine
    explain this command
  • go-tool:tldr:1c2eb go-tool: List available tools.
    $ go tool
    try on your machine
    explain this command
  • go-tool:tldr:4e314 go-tool: Run the go link tool.
    $ go tool link ${path-to-main-o}
    try on your machine
    explain this command
  • go-tool:tldr:db62b go-tool: Display documentation for a specified tool.
    $ go tool ${command} --help
    try on your machine
    explain this command
  • go-tool:tldr:f4c49 go-tool: Print the command that would be executed, but do not execute it (similar to `whereis`).
    $ go tool -n ${command} ${arguments}
    try on your machine
    explain this command
  • go-version:tldr:63dc4 go-version: Print the Go version used to build the named executable file.
    $ go version ${path-to-executable}
    try on your machine
    explain this command
  • go-version:tldr:fc0ef go-version: Print Go version.
    $ go version
    try on your machine
    explain this command
  • go-vet:tldr:35808 go-vet: Display offending lines plus N lines of surrounding context.
    $ go vet -c=${N}
    try on your machine
    explain this command
  • go-vet:tldr:48d2d go-vet: View details and flags for a particular check.
    $ go tool vet help ${check_name}
    try on your machine
    explain this command
  • go-vet:tldr:59972 go-vet: List available checks that can be run with go vet.
    $ go tool vet help
    try on your machine
    explain this command
  • go-vet:tldr:606b7 go-vet: Check the Go package in the current directory.
    $ go vet
    try on your machine
    explain this command
  • go-vet:tldr:9fe8a go-vet: Check the Go package in the specified path.
    $ go vet ${filename_or_directory}
    try on your machine
    explain this command
  • go-vet:tldr:cbab8 go-vet: Output analysis and errors in JSON format.
    $ go vet -json
    try on your machine
    explain this command
  • go:tldr:a7f28 go: Compile a source file into a named executable.
    $ go build -o ${executable} ${file}.go
    try on your machine
    explain this command
  • go:tldr:cec36 go: Compile the package present in the current directory.
    $ go build
    try on your machine
    explain this command
  • go:tldr:d3219 go: Compile and run a source file (it has to contain a `main` package).
    $ go run ${file}.go
    try on your machine
    explain this command
tool overview