Skip to content

Commit

Permalink
fix: invalid position when missing EOL (#5279)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Jan 2, 2025
1 parent 7c9d2f4 commit 15412b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/goanalysis/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/golinters/gofumpt/testdata/gofumpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import "fmt"

func GofumptNewLine() {
fmt.Println( "foo" ) // want "File is not properly formatted"
}
} // want "File is not properly formatted"

0 comments on commit 15412b3

Please sign in to comment.