-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate correct position with comments before the package keyword
Detect the file beginning by using `pass.Fset.File(f.Pos())` instead of assuming that `f.Pos()` is always the beginning of the file. `f.Pos()` is not the beginning of the file when there is for instance a comment before the package, which can lead to wrong reportings of the actual error position. Signed-off-by: Roman Mohr <[email protected]>
- Loading branch information
Showing
3 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package errcheck | ||
|
||
import ( | ||
"golang.org/x/tools/go/analysis/analysistest" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestAnalyzer(t *testing.T) { | ||
packageDir := filepath.Join(analysistest.TestData(), "src/a/") | ||
_ = analysistest.Run(t, packageDir, Analyzer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters