733c4af41d
Tools using go/types sometimes need to implement special handling for certain errors produced by the type-checker. They can offer suggested fixes, expand the error position to surrounding syntax, highlight related syntax (for example in the case of a declaration cycle), link to additional documentation, group errors by category, or correlate errors with signals produced by other static analysis tools. All these require a notion of error identity. Tools need to be able to reliably determine the nature of an error without re-implementing type checking logic or parsing error messages. This CL is a first-pass at adding such an identifier to types.Error: a (for the moment unexported) field containing one of many declared errorCode constants. A wide variety of error code constants are defined, and assigned to type checker errors according to their 'functional equivalence', meaning that they should be ideally be stable under refactoring. With few exceptions, each error code is documented with an example that produces it. This is enforced by tests. When error codes are exported they will represent quite a large API surface. For this reason, as well as the likelihood that error codes will change at the start, both the code field and the codes themselves are initially unexported. gopls will read these fields using reflection during this experimental phase. Others can obviously do the same, provided they accept the lack of forward compatibility. For #42290 Change-Id: I15e3c2bffd2046c20297b1857057d421f633098a Reviewed-on: https://go-review.googlesource.com/c/go/+/264179 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Trust: Robert Griesemer <gri@golang.org> Trust: Robert Findley <rfindley@google.com> |
||
---|---|---|
.github | ||
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
favicon.ico | ||
LICENSE | ||
PATENTS | ||
README.md | ||
robots.txt | ||
SECURITY.md |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 3.0 Attributions license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Download and Install
Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install or load doc/install.html in your web browser for installation instructions.
Install From Source
If a binary distribution is not available for your combination of operating system and architecture, visit https://golang.org/doc/install/source or load doc/install-source.html in your web browser for source installation instructions.
Contributing
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://golang.org/wiki/Questions for a list of places to ask questions about the Go language.