Go Tools

This subrepository holds the source for various packages and tools that support the Go programming language.

Some of the tools, godoc and vet for example, are included in binary Go distributions.

Others, including the Go guru and the test coverage tool, can be fetched with go get.

Packages include a type-checker for Go and an implementation of the Static Single Assignment form (SSA) representation for Go programs.


The easiest way to install is to run go get -u You can also manually git clone the repository to $GOPATH/src/

JS/CSS Formatting

This repository uses prettier to format JS and CSS files.

The version of prettier used is 1.18.2.

It is encouraged that all JS and CSS code be run through this before submitting a change. However, it is not a strict requirement enforced by CI.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see

The main issue tracker for the tools repository is located at Prefix your issue with "x/tools/(your subdir):" in the subject line, so it is easy to find.

Expand ▾ Collapse ▴


Path Synopsis
benchmark/parse Package parse provides support for parsing benchmark results as generated by 'go test -bench'.
blog Package blog implements a web server for articles written in present format.
blog/atom Package atom defines XML data structures for an Atom feed.
cmd/auth/authtest authtest is a diagnostic tool for implementations of the GOAUTH protocol described in
cmd/auth/cookieauth cookieauth uses a “Netscape cookie file” to implement the GOAUTH protocol described in
cmd/auth/gitauth gitauth uses 'git credential' to implement the GOAUTH protocol described in
cmd/auth/netrcauth netrcauth uses a .netrc file (or _netrc file on Windows) to implement the GOAUTH protocol described in
cmd/benchcmp The benchcmp command displays performance changes between benchmarks.
cmd/bundle Bundle creates a single-source-file version of a source package suitable for inclusion in a particular target package.
cmd/callgraph callgraph: a tool for reporting the call graph of a Go program.
cmd/compilebench Compilebench benchmarks the speed of the Go compiler.
cmd/cover Cover is a program for analyzing the coverage profiles generated by 'go test -coverprofile=cover.out'.
cmd/digraph The digraph command performs queries over unlabelled directed graphs represented in text form.
cmd/eg The eg command performs example-based refactoring.
cmd/fiximports The fiximports command fixes import declarations to use the canonical import path for packages that have an "import comment" as defined by
cmd/getgo The getgo command installs Go to the user's system.
cmd/getgo/server Command server serves, redirecting users to the appropriate getgo installer based on the request path.
cmd/go-contrib-init The go-contrib-init command helps new Go contributors get their development environment set up for the Go contribution process.
cmd/godex The godex command prints (dumps) exported information of packages or selected package objects.
cmd/godoc Godoc extracts and generates documentation for Go programs.
cmd/goimports Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones.
cmd/gomvpkg The gomvpkg command moves go packages, updating import declarations.
cmd/gorename The gorename command performs precise type-safe renaming of identifiers in Go source code.
cmd/gotype The gotype command, like the front-end of a Go compiler, parses and type-checks a single Go package.
cmd/goyacc Goyacc is a version of yacc for Go.
cmd/guru guru: a tool for answering questions about Go source code.
cmd/guru/serial Package serial defines the guru's schema for -json output.
cmd/html2article This program takes an HTML file and outputs a corresponding article file in present format.
cmd/present Present displays slide presentations and articles.
cmd/present2md Present2md converts legacy-syntax present files to Markdown-syntax present files.
cmd/splitdwarf Splitdwarf uncompresses and copies the DWARF segment of a Mach-O executable into the "dSYM" file expected by lldb and ports of gdb on OSX.
cmd/splitdwarf/internal/macho Package macho implements access to Mach-O object files.
cmd/ssadump ssadump: a tool for displaying and interpreting the SSA form of Go programs.
cmd/stress The stress utility is intended for catching sporadic failures.
cmd/stringer Stringer is a tool to automate the creation of methods that satisfy the fmt.Stringer interface.
cmd/toolstash Toolstash provides a way to save, run, and restore a known good copy of the Go toolchain and to compare the object files generated by two toolchains.
container/intsets Package intsets provides Sparse, a compact and fast representation for sparse sets of int values.
cover Package cover provides support for parsing coverage profiles generated by "go test -coverprofile=cover.out".
go/analysis Package analysis defines the interface between a modular static analysis and an analysis driver program.
go/analysis/analysistest Package analysistest provides utilities for testing analyzers.
go/analysis/internal/analysisflags Package analysisflags defines helpers for processing flags of analysis driver tools.
go/analysis/internal/checker Package checker defines the implementation of the checker commands.
go/analysis/internal/facts Package facts defines a serializable set of analysis.Fact.
go/analysis/multichecker Package multichecker defines the main function for an analysis driver with several analyzers.
go/analysis/passes/asmdecl Package asmdecl defines an Analyzer that reports mismatches between assembly files and Go declarations.
go/analysis/passes/assign Package assign defines an Analyzer that detects useless assignments.
go/analysis/passes/atomic Package atomic defines an Analyzer that checks for common mistakes using the sync/atomic package.
go/analysis/passes/atomicalign Package atomicalign defines an Analyzer that checks for non-64-bit-aligned arguments to sync/atomic functions.
go/analysis/passes/bools Package bools defines an Analyzer that detects common mistakes involving boolean operators.
go/analysis/passes/buildssa Package buildssa defines an Analyzer that constructs the SSA representation of an error-free package and returns the set of all functions within it.
go/analysis/passes/buildtag Package buildtag defines an Analyzer that checks build tags.
go/analysis/passes/cgocall Package cgocall defines an Analyzer that detects some violations of the cgo pointer passing rules.
go/analysis/passes/composite Package composite defines an Analyzer that checks for unkeyed composite literals.
go/analysis/passes/copylock Package copylock defines an Analyzer that checks for locks erroneously passed by value.
go/analysis/passes/ctrlflow Package ctrlflow is an analysis that provides a syntactic control-flow graph (CFG) for the body of a function.
go/analysis/passes/deepequalerrors Package deepequalerrors defines an Analyzer that checks for the use of reflect.DeepEqual with error values.
go/analysis/passes/errorsas The errorsas package defines an Analyzer that checks that the second argument to errors.As is a pointer to a type implementing error.
go/analysis/passes/findcall Package findcall defines an Analyzer that serves as a trivial example and test of the Analysis API.
go/analysis/passes/findcall/cmd/findcall The findcall command runs the findcall analyzer.
go/analysis/passes/httpresponse Package httpresponse defines an Analyzer that checks for mistakes using HTTP responses.
go/analysis/passes/ifaceassert Package ifaceassert defines an Analyzer that flags impossible interface-interface type assertions.
go/analysis/passes/ifaceassert/cmd/ifaceassert The ifaceassert command runs the ifaceassert analyzer.
go/analysis/passes/inspect Package inspect defines an Analyzer that provides an AST inspector ( for the syntax trees of a package.
go/analysis/passes/internal/analysisutil Package analysisutil defines various helper functions used by two or more packages beneath go/analysis.
go/analysis/passes/loopclosure Package loopclosure defines an Analyzer that checks for references to enclosing loop variables from within nested functions.
go/analysis/passes/lostcancel Package lostcancel defines an Analyzer that checks for failure to call a context cancellation function.
go/analysis/passes/lostcancel/cmd/lostcancel The lostcancel command applies the analysis to the specified packages of Go source code.
go/analysis/passes/nilfunc Package nilfunc defines an Analyzer that checks for useless comparisons against nil.
go/analysis/passes/nilness Package nilness inspects the control-flow graph of an SSA function and reports errors such as nil pointer dereferences and degenerate nil pointer comparisons.
go/analysis/passes/nilness/cmd/nilness The nilness command applies the analysis to the specified packages of Go source code.
go/analysis/passes/pkgfact The pkgfact package is a demonstration and test of the package fact mechanism.
go/analysis/passes/printf Package printf defines an Analyzer that checks consistency of Printf format strings and arguments.
go/analysis/passes/shadow Package shadow defines an Analyzer that checks for shadowed variables.
go/analysis/passes/shadow/cmd/shadow The shadow command runs the shadow analyzer.
go/analysis/passes/shift Package shift defines an Analyzer that checks for shifts that exceed the width of an integer.
go/analysis/passes/sortslice Package sortslice defines an Analyzer that checks for calls to sort.Slice that do not use a slice type as first argument.
go/analysis/passes/stdmethods Package stdmethods defines an Analyzer that checks for misspellings in the signatures of methods similar to well-known interfaces.
go/analysis/passes/stringintconv Package stringintconv defines an Analyzer that flags type conversions from integers to strings.
go/analysis/passes/stringintconv/cmd/stringintconv The stringintconv command runs the stringintconv analyzer.
go/analysis/passes/structtag Package structtag defines an Analyzer that checks struct field tags are well formed.
go/analysis/passes/tests Package tests defines an Analyzer that checks for common mistaken usages of tests and examples.
go/analysis/passes/unmarshal The unmarshal package defines an Analyzer that checks for passing non-pointer or non-interface types to unmarshal and decode functions.
go/analysis/passes/unmarshal/cmd/unmarshal The unmarshal command runs the unmarshal analyzer.
go/analysis/passes/unreachable Package unreachable defines an Analyzer that checks for unreachable code.
go/analysis/passes/unsafeptr Package unsafeptr defines an Analyzer that checks for invalid conversions of uintptr to unsafe.Pointer.
go/analysis/passes/unusedresult Package unusedresult defines an analyzer that checks for unused results of calls to certain pure functions.
go/analysis/singlechecker Package singlechecker defines the main function for an analysis driver with only a single analysis.
go/analysis/unitchecker The unitchecker package defines the main function for an analysis driver that analyzes a single compilation unit during a build.
go/ast/astutil Package astutil contains common utilities for working with the Go AST.
go/ast/inspector Package inspector provides helper functions for traversal over the syntax trees of a package, including node filtering by type, and materialization of the traversal stack.
go/buildutil Package buildutil provides utilities related to the go/build package in the standard library.
go/callgraph Package callgraph defines the call graph and various algorithms and utilities to operate on it.
go/callgraph/cha Package cha computes the call graph of a Go program using the Class Hierarchy Analysis (CHA) algorithm.
go/callgraph/rta This package provides Rapid Type Analysis (RTA) for Go, a fast algorithm for call graph construction and discovery of reachable code (and hence dead code) and runtime types.
go/callgraph/static Package static computes the call graph of a Go program containing only static call edges.
go/cfg Package cfg constructs a simple control-flow graph (CFG) of the statements and expressions within a single function.
go/expect Package expect provides support for interpreting structured comments in Go source code as test expectations.
go/gccgoexportdata Package gccgoexportdata provides functions for reading export data files containing type information produced by the gccgo compiler.
go/gcexportdata Package gcexportdata provides functions for locating, reading, and writing export data files containing type information produced by the gc compiler.
go/internal/gccgoimporter Package gccgoimporter implements Import for gccgo-generated object files.
go/internal/gcimporter Package gcimporter provides various functions for reading gc-generated object files that can be used to implement the Importer interface defined by the Go 1.5 standard library package.
go/internal/packagesdriver Package packagesdriver fetches type sizes for go/packages and go/analysis.
go/loader Package loader loads a complete Go program from source code, parsing and type-checking the initial packages plus their transitive closure of dependencies.
go/packages Package packages loads Go packages for inspection and analysis.
go/packages/gopackages The gopackages command is a diagnostic tool that demonstrates how to use to load, parse, type-check, and print one or more Go packages.
go/packages/packagestest Package packagestest creates temporary projects on disk for testing go tools on.
go/pointer Package pointer implements Andersen's analysis, an inclusion-based pointer analysis algorithm first described in (Andersen, 1994).
go/ssa Package ssa defines a representation of the elements of Go programs (packages, types, functions, variables and constants) using a static single-assignment (SSA) form intermediate representation (IR) for the bodies of functions.
go/ssa/interp Package ssa/interp defines an interpreter for the SSA representation of Go programs.
go/types/objectpath Package objectpath defines a naming scheme for types.Objects (that is, named entities in Go programs) relative to their enclosing package.
go/types/typeutil Package typeutil defines various utilities for types, such as Map, a mapping from types.Type to interface{} values.
go/vcs Package vcs exposes functions for resolving import paths and using version control systems, which can be used to implement behavior similar to the standard "go get" command.
godoc Package godoc is a work-in-progress (2013-07-17) package to begin splitting up the godoc binary into multiple pieces.
godoc/analysis Package analysis performs type and pointer analysis and generates mark-up for the Go source view.
godoc/golangorgenv Package golangorgenv provides environment information for programs running at and its subdomains.
godoc/redirect Package redirect provides hooks to register HTTP handlers that redirect old godoc paths to their new equivalents and assist in accessing the issue tracker, wiki, code review system, etc.
godoc/static Package static exports a map of static file content that supports the godoc user interface.
godoc/util Package util contains utility types and functions for godoc.
godoc/vfs Package vfs defines types for abstract file system access and provides an implementation accessing the file system of the underlying OS.
godoc/vfs/gatefs Package gatefs provides an implementation of the FileSystem interface that wraps another FileSystem and limits its concurrency.
godoc/vfs/httpfs Package httpfs implements http.FileSystem using a godoc vfs.FileSystem.
godoc/vfs/mapfs Package mapfs file provides an implementation of the FileSystem interface based on the contents of a map[string]string.
godoc/vfs/zipfs Package zipfs file provides an implementation of the FileSystem interface based on the contents of a .zip file.
imports Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
internal/analysisinternal Package analysisinternal exposes internal-only fields from go/analysis.
internal/event Package event provides a set of packages that cover the main concepts of telemetry in an implementation agnostic way.
internal/event/core Package core provides support for event based telemetry.
internal/event/export/eventtest Package eventtest supports logging events to a test.
internal/event/export/metric Package metric aggregates events into metrics that can be exported.
internal/event/export/ocagent Package ocagent adds the ability to export all telemetry to an ocagent.
internal/fastwalk Package fastwalk provides a faster version of filepath.Walk for file system scanning tools.
internal/gocommand Package gocommand is a helper for calling the go command.
internal/gopathwalk Package gopathwalk is like filepath.Walk but specialized for finding Go packages, particularly in $GOPATH and $GOROOT.
internal/imports Package imports implements a Go pretty-printer (like package "go/format") that also adds or removes import statements as necessary.
internal/jsonrpc2 Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
internal/jsonrpc2/servertest Package servertest provides utilities for running tests against a remote LSP server.
internal/lsp Package lsp implements LSP for gopls.
internal/lsp/analysis/fillreturns Package fillreturns defines an Analyzer that will attempt to automatically fill in a return statement that has missing values with zero value elements.
internal/lsp/analysis/fillstruct Package fillstruct defines an Analyzer that automatically fills in a struct declaration with zero value elements for each field.
internal/lsp/analysis/nonewvars Package nonewvars defines an Analyzer that applies suggested fixes to errors of the type "no new variables on left side of :=".
internal/lsp/analysis/noresultvalues Package noresultvalues defines an Analyzer that applies suggested fixes to errors of the type "no result values expected".
internal/lsp/analysis/simplifycompositelit Package simplifycompositelit defines an Analyzer that simplifies composite literals.
internal/lsp/analysis/simplifyrange Package simplifyrange defines an Analyzer that simplifies range statements.
internal/lsp/analysis/simplifyslice Package simplifyslice defines an Analyzer that simplifies slice statements.
internal/lsp/analysis/undeclaredname Package undeclaredname defines an Analyzer that applies suggested fixes to errors of the type "undeclared name: %s".
internal/lsp/analysis/unusedparams Package unusedparams defines an analyzer that checks for unused parameters of functions.
internal/lsp/browser Package browser provides utilities for interacting with users' browsers.
internal/lsp/cache Package cache implements the caching layer for gopls.
internal/lsp/cmd Package cmd handles the gopls command line.
internal/lsp/cmd/test Package cmdtest contains the test suite for the command line behavior of gopls.
internal/lsp/debug Package debug exports debug information for gopls.
internal/lsp/debug/tag Package tag provides the labels used for telemetry throughout gopls.
internal/lsp/diff Package diff supports a pluggable diff algorithm.
internal/lsp/diff/difftest Package difftest supplies a set of tests that will operate on any implementation of a diff algorithm as exposed by ""
internal/lsp/diff/myers Package myers implements the Myers diff algorithm.
internal/lsp/fake Package fake provides fake implementations of a text editor, LSP client plugin, and Sandbox environment for use in tests.
internal/lsp/fuzzy Package fuzzy implements a fuzzy matching algorithm.
internal/lsp/helper Invoke with //go:generate helper/helper -t Server -d protocol/tsserver.go -u lsp -o server_gen.go invoke in internal/lsp
internal/lsp/lsprpc Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
internal/lsp/mod Package mod provides core features related to go.mod file handling for use by Go editors and tools.
internal/lsp/protocol Package protocol contains the structs that map directly to the wire format of the "Language Server Protocol".
internal/lsp/regtest Package regtest provides a framework for writing gopls regression tests.
internal/lsp/snippet Package snippet implements the specification for the LSP snippet format.
internal/lsp/source Package source provides core features for use by Go editors and tools.
internal/lsp/tests Package tests exports functionality to be used across a variety of gopls tests.
internal/memoize Package memoize supports memoizing the return values of functions with idempotent results that are expensive to compute.
internal/packagesinternal Package packagesinternal exposes internal-only fields from go/packages.
internal/proxydir Package proxydir provides functions for writing module data to a directory in proxy format, so that it can be used as a module proxy by setting GOPROXY="file://<dir>".
internal/span Package span contains support for representing with positions and ranges in text files.
internal/stack Package stack provides support for parsing standard goroutine stack traces.
internal/stack/gostacks The gostacks command processes stdin looking for things that look like stack traces and simplifying them to make the log more readable.
internal/testenv Package testenv contains helper functions for skipping tests based on which tools are present in the environment.
internal/tool Package tool is a harness for writing Go tools.
internal/xcontext Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
playground Package playground registers HTTP handlers at "/compile" and "/share" that proxy requests to the playground service.
playground/socket Package socket implements an WebSocket-based playground backend.
present Package present implements parsing and rendering of present files, which can be slide presentations as in or articles as in (the Go blog).
refactor/eg Package eg implements the example-based refactoring tool whose command-line is defined in
refactor/importgraph Package importgraph computes the forward and reverse import dependency graphs for all packages in a Go workspace.
refactor/rename Package rename contains the implementation of the 'gorename' command whose main function is in
refactor/satisfy Package satisfy inspects the type-checked ASTs of Go packages and reports the set of discovered type constraints of the form (lhs, rhs Type) where lhs is a non-trivial interface, rhs satisfies this interface, and this fact is necessary for the package to be well-typed.
txtar Package txtar implements a trivial text-based file archive format.
MODULE gopls