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 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

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 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

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/ .

@golang golang locked and limited conversation to collaborators Jul 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants