Comments (6)
E.g. Some live code from our repo that uses this style: https://github.com/ethereum/go-ethereum/blob/master/accounts/usbwallet/wallet.go#L443 Here I think any added new line would just make it harder to read.
from gofumpt.
Oh, one more instance where I think this is useful. After a inline-defined goroutine launch without any parameters:
go func() {
// Do something
}()
noNeedForEmptyLineBeforeThis()
from gofumpt.
Thanks for filing this issue. I mostly agree with the sentiment, but I worry that this would be too agressive as a rule. When separating chunks of code, I don't think a comment is always enough. It can be enough if the code is simple and short, and if you're used to that style, but in reality not much Go code follows that style.
For example, I opened a random file from the Go standard library, and found multiple instances that don't follow this style, like https://golang.org/src/testing/testing.go#L767. In that case, you'd force the author to either move or add a comment, and I don't think the result would be more readable or more consistent.
One of the driving forces in these rules is to enforce what 95% of idiomatic Go code already follows. While you can argue that this would be something useful for some projects, I think it's not something that's widespread or a net readability win (see above).
from gofumpt.
This is extraordinarily subjective and I don't think there's any consensus that this approach is better or more readable.
I personally find it maddening to try to read a function that is 100 lines long with absolutely no blank lines to break up logical pieces. Whitespace can and should be used to group logical blocks of functionality.
from gofumpt.
This is extraordinarily subjective and I don't think there's any consensus that this approach is better or more readable.
Hence why I wrote "opinionated" and "wondering".
I personally find it maddening to try to read a function that is 100 lines long with absolutely no blank lines to break up logical pieces.
Apart from some extreme math heavy code, I don't think any program exists out there that is 100 lines long without a single for
loop of if
branch. If you do have those however, you already have empty lines on the closing braces.
I personally find it maddening to try to read a function that is 100 lines long with absolutely no blank lines comments to break up explain logical pieces.
from gofumpt.
While gofumpt is even more opinionated than gofmt, it tries to follow the already-present standards. I think this is too ambitious and controversial for the tool. And I definitely don't want to add flags :)
@karalabe if you can come up with a rule or heuristic that would keep most existing idiomatic Go code intact, I'm happy to consider it. Otherwise, this is unlikely to happen right now.
from gofumpt.
Related Issues (20)
- Tracking issue: go release tag fails semver version check HOT 2
- Members of struct after Pass-through type inside struct's formatting is ignored HOT 2
- install as a CLI HOT 2
- Remove empty lines in if and for similar to functions HOT 13
- Proposal: Clothe naked returns HOT 10
- panic while handling some //line directives HOT 2
- Breaks import comment HOT 1
- feature: Enforce line breaks between multiline function calls with func() argument HOT 1
- add simplifications for Go 1.22 HOT 1
- panic: invalid semver string: "v1.22rc2" HOT 1
- Making every added formatting rule Optional HOT 3
- missing binary release at latest version-v0.6.0 HOT 1
- Single import should not be grouped with parentheses
- Generated file not ignored HOT 2
- prevent indentation confusion
- Gofumpt removing newlines before comments HOT 7
- gofumpt is very slow when `go` is behind an asdf shim HOT 3
- Split long lines only available behind environment string
- Publish v1 HOT 2
- how to ignore certain folders?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gofumpt.