Documentation ¶
Index ¶
- func PrintPrettyError(w io.Writer, filename string, data []byte, err error) bool
- type Error
- type Lines
- type Locatable
- type Location
- type Locator
- func (l Locator) Field(key string) (loc Locator)
- func (l Locator) Index(idx int) (loc Locator)
- func (l Locator) Key(key string) (loc Locator)
- func (l Locator) Location() (Location, bool)
- func (l *Locator) MarshalYAML(n *yaml.Node) error
- func (l *Locator) SetLocation(loc Location)
- func (l *Locator) UnmarshalYAML(n *yaml.Node) error
- type PrintListingOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
Error is a wrapper for an error that has a location.
func (*Error) FormatError ¶
FormatError implements errors.Formatter.
type Lines ¶
type Lines struct {
// contains filtered or unexported fields
}
Lines is a sorted slice of newline offsets.
func (Lines) Line ¶
Line returns offset range of the line.
NOTE: the line number is 1-based. Returns (-1, -1) if the line is invalid.
func (Lines) PrintListing ¶
PrintListing prints given message with line number and file listing to the writer.
The context parameter defines the number of lines to print before and after.
type Locatable ¶
type Locatable interface { // SetLocation sets the location of the value. SetLocation(Location) // Location returns the location of the value if it is set. Location() (Location, bool) }
Locatable is an interface for JSON value location store.
type Location ¶
Location is a JSON value location.
func (Location) Field ¶
Field tries to find the child node using given key and returns its location. If such node is not found or parent node is not a mapping, Field returns location of the parent node.
NOTE: child location will point to the value node, not to the key node. Use Key if you want location of the key.
func (Location) Index ¶
Index tries to find the child node using given index and returns its location. If such node is not found or parent node is not a sequence, Field returns location of the parent node.
func (Location) Key ¶
Key tries to find the child node using given key and returns its location. If such node is not found or parent node is not a mapping, Key returns location of the parent node.
NOTE: child location will point to the key node, not to the value node. Use Field if you want location of the value.
func (Location) WithFilename ¶
WithFilename prints the location with the given filename.
If filename is empty, the location is printed as is.
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator stores the Location of a JSON value.
func (Locator) Field ¶
Field tries to find the child node using given key and returns its location.
See Field method of Location.
func (Locator) Index ¶
Index tries to find the child node using given index and returns its location.
See Index method of Location.
func (Locator) Key ¶
Key tries to find the child node using given key and returns its location.
See Key method of Location.
func (*Locator) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (*Locator) SetLocation ¶
SetLocation sets the location of the value.
type PrintListingOptions ¶
type PrintListingOptions struct { // Filename is a name of the file to print with location. Filename string // Context is the number of lines to print before and after the error line. // // If is zero, the default value 5 is used. Context int // If is nil, the default value color.New(color.FgRed) is used. ErrColor *color.Color // If is nil, the default value color.New(color.Reset) is used. PlainColor *color.Color }
PrintListingOptions is a set of options for PrintListing.