The Position struct describes a specific location in the source code (filename, offset, line, and column). Use the String() method to get a formatted string representation.
Supported formats for String():
file:line:column (Valid position with filename)line:column (Valid position without filename)file (Invalid position with filename)- (Invalid position without filename)
type Position struct {
Filename string // The filename where the error occurred, if any
Offset int // The src offset
Line int // The line number, starting at 1
Column int // The column number, starting at 1 (The character count)
}
// Example of String() output:
// "example.js:1:5"