Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Linter to rewrite err=foo; if err to if err=foo; err #4471

Closed
grosser opened this issue Mar 8, 2024 · 5 comments
Closed

Linter to rewrite err=foo; if err to if err=foo; err #4471

grosser opened this issue Mar 8, 2024 · 5 comments
Labels
linter: idea idea of a linter

Comments

@grosser
Copy link

grosser commented Mar 8, 2024

Your feature request related to a problem? Please describe.

rewrite

err = foo
if err != nil {

into

if err = foo; err != nil {

so our code looks consistent

Describe the solution you'd like.

automatic reformat

Describe alternatives you've considered.

manually reformatting

Additional context.

No response

@grosser grosser added the enhancement New feature or improvement label Mar 8, 2024
Copy link

boring-cyborg bot commented Mar 8, 2024

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@grosser grosser changed the title Linter to rewrite err = foo; if err != nil to if err = foo; err != nil { Linter to rewrite err=foo; if err to if err=foo; err Mar 8, 2024
@ldez ldez added linter: idea idea of a linter and removed enhancement New feature or improvement labels Mar 8, 2024
@ldez
Copy link
Member

ldez commented Mar 8, 2024

Hello,

FYI golangci-lint is a wrapper around linters.

Also, I think you are looking for something like ifshort or errifinline.

ifshort has been archived.

errifinline is will maybe be transformed #4385 (comment)

@grosser
Copy link
Author

grosser commented Mar 8, 2024

awesome, thx!

@grosser
Copy link
Author

grosser commented Mar 8, 2024

can I use this without the PR being merged ?
... don't really want to setup a whole new flow for this 1 linter

@bombsimon
Copy link
Member

Not unless you build golangci-lint from the branch of the PR, but then you'll miss other things instead unless you rebase manually.

@golangci golangci locked and limited conversation to collaborators May 26, 2024
@ldez ldez converted this issue into discussion #4755 May 26, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
linter: idea idea of a linter
Projects
None yet
Development

No branches or pull requests

3 participants