File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -81,12 +81,18 @@ func runGoHeader(pass *analysis.Pass, conf *goheader.Configuration) error {
8181 // Inspired by https://github.com/denis-tingaikin/go-header/blob/4c75a6a2332f025705325d6c71fff4616aedf48f/analyzer.go#L85-L92
8282 if len (file .Comments ) > 0 && file .Comments [0 ].Pos () < file .Package {
8383 if ! strings .HasPrefix (file .Comments [0 ].List [0 ].Text , "/*" ) {
84- // When the comment are "//" there is a one character offset.
84+ // When the comment is "//" there is a one character offset.
8585 offset = 1
8686 }
8787 commentLine = goanalysis .GetFilePositionFor (pass .Fset , file .Comments [0 ].Pos ()).Line
8888 }
8989
90+ // Skip issues related to build directives.
91+ // https://github.com/denis-tingaikin/go-header/issues/18
92+ if issue .Location ().Position - offset < 0 {
93+ continue
94+ }
95+
9096 diag := analysis.Diagnostic {
9197 Pos : f .LineStart (issue .Location ().Line + 1 ) + token .Pos (issue .Location ().Position - offset ), // The position of the first divergence.
9298 Message : issue .Message (),
You can’t perform that action at this time.
0 commit comments