Skip to content

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

Open
JamyDev wants to merge 5 commits into
daixiang0:masterfrom
JamyDev:format-always
Open

feat(format): add --format-always flag#162
JamyDev wants to merge 5 commits into
daixiang0:masterfrom
JamyDev:format-always

Conversation

@JamyDev

@JamyDev JamyDev commented Jul 13, 2023

Copy link
Copy Markdown

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
Copy Markdown
Owner

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

@JamyDev

JamyDev commented Jul 14, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown
Owner

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

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

JamyDev commented Jul 17, 2023

Copy link
Copy Markdown
Author

updated!

Comment thread README.md Outdated
Comment thread cmd/gci/gcicommand.go Outdated
Signed-off-by: Jamy Timmermans <jamy@uber.com>
Comment thread README.md Outdated
Signed-off-by: Jamy Timmermans <jamy@uber.com>
@daixiang0

Copy link
Copy Markdown
Owner

@JamyDev seems still conflict :(

@JamyDev

JamyDev commented Oct 31, 2023

Copy link
Copy Markdown
Author

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.

2 participants