MCPcopy Create free account
hub / github.com/bracesdev/errtrace / optoutLines

Function optoutLines

cmd/errtrace/main.go:1184–1202  ·  view source on GitHub ↗

optoutLines returns the line numbers that have a comment in the form: //errtrace:skip It may be followed by other text, e.g., //errtrace:skip // for reasons

(
	fset *token.FileSet,
	comments []*ast.CommentGroup,
)

Source from the content-addressed store, hash-verified

1182//
1183// //errtrace:skip // for reasons
1184func optoutLines(
1185 fset *token.FileSet,
1186 comments []*ast.CommentGroup,
1187) map[int]int {
1188 lines := make(map[int]int)
1189 for _, cg := range comments {
1190 if len(cg.List) > 1 {
1191 // skip multiline comments which are full line comments, not tied to a return.
1192 continue
1193 }
1194
1195 c := cg.List[0]
1196 if _errtraceSkip.MatchString(c.Text) {
1197 lineNo := fset.Position(c.Pos()).Line
1198 lines[lineNo] = 0
1199 }
1200 }
1201 return lines
1202}
1203
1204func nVars(prefix string, n int) []string {
1205 vars := make([]string, n)

Callers 2

TestOptoutLinesFunction · 0.85
parseFileMethod · 0.85

Calls 1

PosMethod · 0.65

Tested by 1

TestOptoutLinesFunction · 0.68