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

feat(format): add --format-always flag #162

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

JamyDev
Copy link

@JamyDev JamyDev commented Jul 13, 2023

Add the option to always run goFormat.Source even if there are no imports.

Justification:

Currently we have to run 2 formatters to make sure everything is properly formatter (gofmt and gci). Yet any fime that has imports and gets formatted by gci, doesn't actually need to get ran through gofmt. This eliminates this double tool problem.

Signed-off-by: Jamy Timmermans <jamy@uber.com>
@daixiang0
Copy link
Owner

Do you mean that you have codes without import block so that you can not disable gofmt?

@JamyDev
Copy link
Author

JamyDev commented Jul 14, 2023

I have configured gci as the default formatter for my project. Which also means configuring it as the default format on save in my IDE. Right now, the formatting doesn't happen for files that don't have an import block, since gci just skips those. Adding this flag basically makes it fall back to gofmt fir any files without imports so the rest of the file is properly formatted.

@daixiang0
Copy link
Owner

@JamyDev please update README then we can make it land.

Signed-off-by: Jamy Timmermans <jamy@uber.com>
@JamyDev
Copy link
Author

JamyDev commented Jul 17, 2023

updated!

README.md Outdated Show resolved Hide resolved
cmd/gci/gcicommand.go Outdated Show resolved Hide resolved
Signed-off-by: Jamy Timmermans <jamy@uber.com>
README.md Outdated Show resolved Hide resolved
Signed-off-by: Jamy Timmermans <jamy@uber.com>
@daixiang0
Copy link
Owner

@JamyDev seems still conflict :(

@JamyDev
Copy link
Author

JamyDev commented Oct 31, 2023

Fixed @daixiang0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants