DiagnosticPosition returns the 1-based line and column for err in msg when err carries a byte offset, or false otherwise.
(msg string, err error)
| 110 | // DiagnosticPosition returns the 1-based line and column for err in msg when |
| 111 | // err carries a byte offset, or false otherwise. |
| 112 | func DiagnosticPosition(msg string, err error) (line, column int, ok bool) { |
| 113 | var pe *syntax.ParseError |
| 114 | if !errors.As(err, &pe) { |
| 115 | return 0, 0, false |
| 116 | } |
| 117 | pos := syntax.Locate(msg, pe.Offset) |
| 118 | return pos.Line, pos.Column, true |
| 119 | } |
no outgoing calls