Documentation ¶
Index ¶
Constants ¶
const BugLine = `Cannot render line properly, please fill a bug report`
BugLine is a fallback line when the line is not available.
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.
func (*Error) PrettyPrint ¶ added in v0.53.0
PrettyPrint prints the error in a pretty way and returns true if it was printed successfully.
type File ¶ added in v0.53.0
type File struct { // Name is the file name. Name string // Source is the path or URL of the file. Source string // Lines stores newline offsets. Lines Lines }
File is a source file.
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 { // SetPosition sets the position of the value. SetPosition(Position) // Position returns the position of the value if it is set. Position() (Position, bool) }
Locatable is an interface for JSON value position store.
type Locator ¶
type Locator struct {
// contains filtered or unexported fields
}
Locator stores the Position of a JSON value.
func (Locator) Field ¶
Field tries to find the child node using given key and returns its position.
See Field method of Position.
func (Locator) Index ¶
Index tries to find the child node using given index and returns its position.
See Index method of Position.
func (Locator) Key ¶
Key tries to find the child node using given key and returns its position.
See Key method of Position.
func (*Locator) SetPosition ¶ added in v0.53.0
SetPosition sets the position of the value.
type Position ¶ added in v0.53.0
Position is a JSON value position.
func (Position) Field ¶ added in v0.53.0
Field tries to find the child node using given key and returns its position. If such node is not found or parent node is not a mapping, Field returns position of the parent node.
NOTE: child position will point to the value node, not to the key node. Use Key if you want position of the key.
func (*Position) FromNode ¶ added in v0.53.0
FromNode sets the position of the value from the given node.
func (Position) Index ¶ added in v0.53.0
Index tries to find the child node using given index and returns its position. If such node is not found or parent node is not a sequence, Field returns position of the parent node.
func (Position) Key ¶ added in v0.53.0
Key tries to find the child node using given key and returns its position. If such node is not found or parent node is not a mapping, Key returns position of the parent node.
NOTE: child position will point to the key node, not to the value node. Use Field if you want position of the value.
func (Position) WithFilename ¶ added in v0.53.0
WithFilename prints the position with the given filename.
If filename is empty, the position is printed as is.
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.
func (PrintListingOptions) WithoutColor ¶ added in v0.52.0
func (o PrintListingOptions) WithoutColor() PrintListingOptions
WithoutColor creates a copy of the options with disabled color.