blob: 5cd8f0ac6e93f916d06eac160da03612962b0018 [file] [log] [blame] [view]
Kevin Burke68e087e2017-07-18 21:03:19 -07001# Go Tools
2
Rebecca Stambler39497342020-12-03 17:53:26 -05003[![PkgGoDev](https://pkg.go.dev/badge/golang.org/x/tools)](https://pkg.go.dev/golang.org/x/tools)
4
Alan Donovanb4c45002022-05-03 12:59:16 -04005This repository provides the `golang.org/x/tools` module, comprising
6various tools and packages mostly for static analysis of Go programs,
7some of which are listed below.
8Use the "Go reference" link above for more information about any package.
Kevin Burke68e087e2017-07-18 21:03:19 -07009
Alan Donovanb4c45002022-05-03 12:59:16 -040010It also contains the
11[`golang.org/x/tools/gopls`](https://pkg.go.dev/golang.org/x/tools/gopls)
12module, whose root package is a language-server protocol (LSP) server for Go.
13An LSP server analyses the source code of a project and
14responds to requests from a wide range of editors such as VSCode and
15Vim, allowing them to support IDE-like functionality.
Kevin Burke68e087e2017-07-18 21:03:19 -070016
Alan Donovanb4c45002022-05-03 12:59:16 -040017<!-- List only packages of general interest below. -->
Kevin Burke68e087e2017-07-18 21:03:19 -070018
Alan Donovanb4c45002022-05-03 12:59:16 -040019Selected commands:
Kevin Burke68e087e2017-07-18 21:03:19 -070020
Alan Donovanb4c45002022-05-03 12:59:16 -040021- `cmd/goimports` formats a Go program like `go fmt` and additionally
22 inserts import statements for any packages required by the file
23 after it is edited.
24- `cmd/callgraph` prints the call graph of a Go program.
25- `cmd/digraph` is a utility for manipulating directed graphs in textual notation.
26- `cmd/stringer` generates declarations (including a `String` method) for "enum" types.
27- `cmd/toolstash` is a utility to simplify working with multiple versions of the Go toolchain.
Kevin Burke68e087e2017-07-18 21:03:19 -070028
Alan Donovanb4c45002022-05-03 12:59:16 -040029These commands may be fetched with a command such as
30`go install golang.org/x/tools/cmd/goimports@latest`.
Kevin Burke68e087e2017-07-18 21:03:19 -070031
Alan Donovanb4c45002022-05-03 12:59:16 -040032Selected packages:
33
34- `go/ssa` provides a static single-assignment form (SSA) intermediate
35 representation (IR) for Go programs, similar to a typical compiler,
36 for use by analysis tools.
37
38- `go/packages` provides a simple interface for loading, parsing, and
39 type checking a complete Go program from source code.
40
41- `go/analysis` provides a framework for modular static analysis of Go
42 programs.
43
44- `go/callgraph` provides call graphs of Go programs using a variety
45 of algorithms with different trade-offs.
46
47- `go/ast/inspector` provides an optimized means of traversing a Go
48 parse tree for use in analysis tools.
49
50- `go/cfg` provides a simple control-flow graph (CFG) for a Go function.
51
52- `go/expect` reads Go source files used as test inputs and interprets
53 special comments within them as queries or assertions for testing.
54
55- `go/gcexportdata` and `go/gccgoexportdata` read and write the binary
56 files containing type information used by the standard and `gccgo` compilers.
57
58- `go/types/objectpath` provides a stable naming scheme for named
59 entities ("objects") in the `go/types` API.
60
61Numerous other packages provide more esoteric functionality.
62
63<!-- Some that didn't make the cut:
64
65golang.org/x/tools/benchmark/parse
66golang.org/x/tools/go/ast/astutil
67golang.org/x/tools/go/types/typeutil
68golang.org/x/tools/go/vcs
69golang.org/x/tools/godoc
70golang.org/x/tools/playground
71golang.org/x/tools/present
72golang.org/x/tools/refactor/importgraph
73golang.org/x/tools/refactor/rename
74golang.org/x/tools/refactor/satisfy
75golang.org/x/tools/txtar
76
77-->
78
79## Contributing
80
81This repository uses Gerrit for code changes.
82To learn how to submit changes, see https://golang.org/doc/contribute.html.
83
84The main issue tracker for the tools repository is located at
85https://github.com/golang/go/issues. Prefix your issue with "x/tools/(your
86subdir):" in the subject line, so it is easy to find.
87
88### JavaScript and CSS Formatting
Agniva De Sarker65d52282019-06-26 14:28:00 +053089
90This repository uses [prettier](https://prettier.io/) to format JS and CSS files.
91
92The version of `prettier` used is 1.18.2.
93
94It is encouraged that all JS and CSS code be run through this before submitting
95a change. However, it is not a strict requirement enforced by CI.