-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
goimports --fix not fixing new lines #1373
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
Comments
Note - everything else is fixed except adding the trailing new line |
I just checked with the latest (v1.35.1) version |
I think the issue here is that |
I am also running into this. I tried 1.36.0. The log is below. Every time it runs, it detects the issue with an "INFO Fix issue log", but doesn't seem to fix it. This also affects gofmt. Also: manually running # Removing the newline at the end of a source file
$ truncate -s -1 main.go
$ golangci-lint version
golangci-lint has version 1.36.0 built from 6c25d06 on 2021-01-26T13:14:05Z
$ golangci-lint run -v --no-config --disable-all -E goimports --fix main.go
INFO [lintersdb] Active 1 linters: [goimports]
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 195.815817ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 121.748µs
INFO [linters context/goanalysis] analyzers took 0s with no stages
INFO [runner] Processors filtering stat (out/in): nolint: 1/1, max_from_linter: 1/1, severity-rules: 1/1, path_prefixer: 1/1, cgo: 1/1, filename_unadjuster: 1/1, skip_files: 1/1, identifier_marker: 1/1, path_prettifier: 1/1, source_code: 1/1, max_same_issues: 1/1, path_shortener: 1/1, skip_dirs: 1/1, autogenerated_exclude: 1/1, uniq_by_line: 1/1, max_per_file_from_linter: 1/1, exclude: 1/1, exclude-rules: 1/1, diff: 1/1, sort_results: 1/1
INFO [runner] processing took 236.134µs with stages: nolint: 65.41µs, identifier_marker: 48.707µs, autogenerated_exclude: 23.365µs, source_code: 22.943µs, exclude-rules: 21.731µs, path_prettifier: 21.424µs, skip_dirs: 17.819µs, max_same_issues: 5.865µs, path_shortener: 1.438µs, cgo: 1.341µs, max_per_file_from_linter: 1.217µs, filename_unadjuster: 1.024µs, uniq_by_line: 1.003µs, max_from_linter: 678ns, skip_files: 587ns, diff: 498ns, exclude: 391ns, sort_results: 284ns, severity-rules: 240ns, path_prefixer: 169ns
INFO [runner] linters took 1.168202ms with stages: goimports: 771.342µs
INFO Fix issue &result.Issue{FromLinter:"goimports", Text:"File is not `goimports`-ed", Severity:"", SourceLines:[]string{"}"}, Replacement:(*result.Replacement)(0xc000de6600), Pkg:(*packages.Package)(0xc000dc1320), LineRange:(*result.Range)(nil), Pos:token.Position{Filename:"main.go", Offset:0, Line:7, Column:0}, HunkPos:0, ExpectNoLint:false, ExpectedNoLintLinter:""} with range {7 7}
INFO fixer took 218.234µs with stages: all: 218.234µs
INFO File cache stats: 1 entries of total size 66B
INFO Memory: 4 samples, avg is 71.3MB, max is 71.3MB
INFO Execution took 216.442738ms
$ golangci-lint run -v --no-config --disable-all -E gofmt --fix main.go
...
INFO Fix issue &result.Issue{FromLinter:"gofmt", Text:"File is not `gofmt`-ed with `-s`", Severity:"", SourceLines:[]string{"}"}, Replacement:(*result.Replacement)(0xc0005cb210), Pkg:(*packages.Package)(0xc000ca6c60), LineRange:(*result.Range)(nil), Pos:token.Position{Filename:"main.go", Offset:0, Line:7, Column:0}, HunkPos:0, ExpectNoLint:false, ExpectedNoLintLinter:""} with range {7 7}
... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
When running goimports, golangci-lint will detect a missing newline at EOF, but not apply them:
test.go
NOTE: no newline at end of test.go.
A direct
goimports -w test.go
does fix it.Config:
The text was updated successfully, but these errors were encountered: