Skip to content

Commit

Permalink
gofmt: autofix missing newline at EOF (#3917)
Browse files Browse the repository at this point in the history
  • Loading branch information
kseniadumpling committed Jun 18, 2023
1 parent 7cf30e7 commit 28f0560
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/golinters/gofmt_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ func (p *hunkChangesParser) parseDiffLines(h *diffpkg.Hunk) {
ret = append(ret, dl)
}

// if > 0, then the original file had a 'No newline at end of file' mark
if h.OrigNoNewlineAt > 0 {
dl := diffLine{
originalNumber: currentOriginalLineNumber + 1,
typ: diffLineAdded,
data: "",
}
ret = append(ret, dl)
}

p.lines = ret
}

Expand Down
2 changes: 1 addition & 1 deletion test/testdata/fix/in/gofmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ package p
return 1
}
return 2
}
}

0 comments on commit 28f0560

Please sign in to comment.