diff --git a/pkg/goanalysis/position.go b/pkg/goanalysis/position.go index a386d3bc1434..96328479494b 100644 --- a/pkg/goanalysis/position.go +++ b/pkg/goanalysis/position.go @@ -37,7 +37,7 @@ func GetFilePositionFor(fset *token.FileSet, p token.Pos) token.Position { func EndOfLinePos(f *token.File, line int) token.Pos { var end token.Pos - if line == f.LineCount() { + if line >= f.LineCount() { // missing newline at the end of the file end = f.Pos(f.Size()) } else { diff --git a/pkg/golinters/gofumpt/testdata/gofumpt.go b/pkg/golinters/gofumpt/testdata/gofumpt.go index c72700cecbcf..79cec0a0d8a1 100644 --- a/pkg/golinters/gofumpt/testdata/gofumpt.go +++ b/pkg/golinters/gofumpt/testdata/gofumpt.go @@ -5,4 +5,4 @@ import "fmt" func GofumptNewLine() { fmt.Println( "foo" ) // want "File is not properly formatted" -} +} // want "File is not properly formatted" \ No newline at end of file