Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gofmt: autofix missing newline at EOF #3917

Merged
merged 1 commit into from Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/golinters/gofmt_common.go
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
Expand Up @@ -7,4 +7,4 @@ package p
return 1
}
return 2
}
}