Documentation ¶
Overview ¶
Package diag contains building blocks for formatting and processing diagnostic information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PackCognateErrors ¶ added in v0.19.0
PackCognateErrors combines multiple instances of Error with with the same Type and Context.Name into one:
If called with no errors, it returns nil.
If called with one error, it returns that error itself.
If called with more than one Error, it returns an error that combines all of them. The returned error also implements Shower, and its Error and Show methods avoid duplicating the type and context name of the constituent errors.
Types ¶
type Context ¶
Context is a range of text in a source code. It is typically used for errors that can be associated with a part of the source code, like parse errors and a traceback entry.
Context values should only be constructed using NewContext.
func NewContext ¶
NewContext creates a new Context.
func (*Context) ShowCompact ¶
ShowCompact shows a Context, with no line break between the culprit range description and relevant source excerpt.
type Error ¶
Error represents an error with context that can be showed.
func UnpackCognateErrors ¶ added in v0.19.0
UnpackCognateErrors returns the constituent Error instances in an error and if it is built from PackCognateErrors. Otherwise it returns nil.
type Ranger ¶
type Ranger interface { // Range returns the range associated with the value. Range() Ranging }
Ranger wraps the Range method.
type Ranging ¶
Ranging represents a range [From, To) within an indexable sequence. Structs can embed Ranging to satisfy the Ranger interface.
Ideally, this type would be called Range. However, doing that means structs embedding this type will have Range as a field instead of a method, thus not implementing the Ranger interface.
func MixedRanging ¶
MixedRanging returns a Ranging from the start position of a to the end position of b.
func PointRanging ¶
PointRanging returns a zero-width Ranging at the given point.