Documentation ¶
Overview ¶
Package filepos provides the concept of Position: a source name (usually a file) and line number within that source.
File positions are crucial when reporting errors to the user. It is often even more useful to share the actual source line as well. For this reason Position also contains a cached copy of the source line at the Position.
Not all Position point within a file (e.g. code that is generated). The zero-value of Position (can be created using NewUnknownPosition()) represents this case.
Index ¶
- type Position
- func (p *Position) As4DigitString() string
- func (p *Position) AsCompactString() string
- func (p *Position) AsIntString() string
- func (p *Position) AsString() string
- func (p *Position) DeepCopy() *Position
- func (p *Position) DeepCopyWithLineOffset(offset int) *Position
- func (p *Position) FromMemory() bool
- func (p *Position) GetFile() string
- func (p *Position) GetLine() string
- func (p *Position) IsKnown() bool
- func (p *Position) IsNextTo(otherPosition *Position) bool
- func (p *Position) LineNum() int
- func (p *Position) SetLine(line string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Position ¶
type Position struct {
// contains filtered or unexported fields
}
func NewPosition ¶
func NewPositionInFile ¶ added in v0.48.0
NewPositionInFile returns the Position of line "lineNum" within the file "file"
func NewUnknownPosition ¶
func NewUnknownPosition() *Position
NewUnknownPosition is equivalent of zero value *Position
func NewUnknownPositionInFile ¶ added in v0.48.0
NewUnknownPositionInFile produces a Position of a known file at an unknown line.