Skip to content

Commit f0e8335

Browse files
committed
fix: use the right position
1 parent 65613f3 commit f0e8335

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/golinters/goheader/goheader.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) error {
7272

7373
f := pass.Fset.File(file.Pos())
7474

75-
start := f.LineStart(issue.Location().Line + 1)
75+
commentLine := 1
76+
77+
// Inspired by https://github.com/denis-tingaikin/go-header/blob/4c75a6a2332f025705325d6c71fff4616aedf48f/analyzer.go#L85-L92
78+
if len(file.Comments) > 0 && file.Comments[0].Pos() < file.Package {
79+
commentLine = goanalysis.GetFilePositionFor(pass.Fset, file.Comments[0].Pos()).Line
80+
}
81+
82+
start := f.LineStart(commentLine)
7683

7784
diag := analysis.Diagnostic{
7885
Pos: start,

0 commit comments

Comments
 (0)