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

How to customize gofmt behaviour? #40028

Closed
Paxa opened this issue Jul 3, 2020 · 3 comments
Closed

How to customize gofmt behaviour? #40028

Paxa opened this issue Jul 3, 2020 · 3 comments

Comments

@Paxa
Copy link

@Paxa Paxa commented Jul 3, 2020

Is it possible to disable or customize some gofmt rules?

May be it support some config file? Support for something like .gofmt_config in project folder would be perfect

I prefer to keep spaces around math symbols

a = perPage*(pageNumber+checkNextPageCount-1) + 1
records[len(records)-1]

// I like with spaces
a = perPage * (pageNumber + checkNextPageCount - 1) + 1
records[len(records) - 1]
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 3, 2020

It is an intentional design choice that there are no configuration options for gofmt. The benefit of eliminating bike shed discussion about formatting choices is considered to be more important than the cost of not permitting people to use their preferred style. The usual saying is that gofmt isn't anybody's preferred style, but it's adequate for everybody.

@Paxa
Copy link
Author

@Paxa Paxa commented Jul 3, 2020

Thanks.
Every linting and formatting tool that I've used have configuration. So every team can choose their comfortable style and the use the tool to maintain it

The usual saying is that gofmt isn't anybody's preferred style, but it's adequate for everybody who still using it.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 4, 2020

Well, as I say, this was an intentional choice. It's often said that Go is an opinionated language, and this is one of the opinions that it holds. https://go-proverbs.github.io/ .

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.