MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / DiagnosticPosition

Function DiagnosticPosition

commit/parser.go:112–119  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

110// DiagnosticPosition returns the 1-based line and column for err in msg when
111// err carries a byte offset, or false otherwise.
112func 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}

Callers 2

parserErrorRuleMethod · 0.92
TestCommitHelpersFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestCommitHelpersFunction · 0.74