Skip to content

feat: add rewrite option #2

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

Merged
merged 6 commits into from
Aug 31, 2022
Merged

feat: add rewrite option #2

merged 6 commits into from
Aug 31, 2022

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Aug 31, 2022

golangci/golangci-lint#3171

this PR add a func RunRewrite(filename string, needSimplify bool, rewrite string) ([]byte, error) to support gofmt's -r flag.

The caller from golangci-lint will use newly added method RunRewrite to apply a option rewrite rule.

empty string as rewrite will be ignored.

private methods are added because origin impl has os.Exit(...)

@ldez
Copy link
Member

ldez commented Aug 31, 2022

Can you add a real PR description?

@ldez ldez added the enhancement New feature or request label Aug 31, 2022
@trim21
Copy link
Contributor Author

trim21 commented Aug 31, 2022

@ldez done

@ldez
Copy link
Member

ldez commented Aug 31, 2022

When a PR is not ready:

  • work locally before opening it
  • open your PR as draft

When a PR is open, a review can start, each commit after the opening of the PR requires another review.

Fixing a typo or adding a comment is not a problem but 2600dff is not expected 2 hours after the opening of the PR.

@trim21
Copy link
Contributor Author

trim21 commented Aug 31, 2022

sorry, it's ready to be reviewed now.

@ldez
Copy link
Member

ldez commented Aug 31, 2022

⚠️ I will merge this PR but please don't open a PR on golangci-lint because I would like to change other stuff. ⚠️

@ldez ldez changed the title add golangci rewrite support feat: add rewrite option Aug 31, 2022
@ldez ldez merged commit fadf134 into golangci:master Aug 31, 2022
@trim21 trim21 deleted the rewrite branch August 31, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants