-
Notifications
You must be signed in to change notification settings - Fork 16
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
ci(lint): golangci-lint and fieldalignment #132
Conversation
…golangci-lint so we can get to lint checks and fieldalignement
…s, unecessary conversions (lots of uint64 conversions around uint64 return types)
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #132 +/- ##
==========================================
+ Coverage 63.60% 63.77% +0.16%
==========================================
Files 39 39
Lines 3366 3387 +21
==========================================
+ Hits 2141 2160 +19
- Misses 1060 1062 +2
Partials 165 165 ☔ View full report in Codecov by Sentry. |
🤣 |
That's a relic from the time when int64 was used for heights. I thought we cleaned them up but seems like not |
sync/sync.go
Outdated
// stateLk protects state which represents the current or latest sync | ||
stateLk sync.RWMutex | ||
state State |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so it seems like chasing perfect alignment can affect readability. Locks should be put on top of the field they synchronize.
The new field order does not make any sense to me, unfortunately. I think if we should disable lint for structs where performance gains are negligible, like in the case of singleton structs. Syncer, Exhange, Store, and so forth are meant to be instantiated once in application, meaning that the few bytes we get from realigning them are negligible., while readability and field grouping, in particular in such more complicated structs, are more important.
Perhaps we could use the ignore lint comment for such structs where we deliberately trade performance for readability
…structs with sync primitives at top of structs for better reading vs optimization, utilize //nolint:govet where we decide on form over function
@Wondertan re-aligned some back to reflect idioms etc, have a look and point out any others that maybe want some re-jiggling, not too far from original in most cases |
IMO it will be better to not merge these changes 'cause Go will start doing this automatically, see accepted proposal golang/go#66408 |
Agree. Do you mean its fully automatic? My read is that it requires importing and embedding the layout struct |
Of course not. Implicit field from |
At suggestion and request of @Wondertan, implemented govet field alignment linting for struct alignment/padding checks, and subsequently committed fixes for them, as we did in celestiaorg/celestia-node#2856
Needed to take a bit of a quest to get here, steps from volume 1:
golangci-lint
for the repo (using same .golangci.yml we use in celestia-node)lint
job thatbuild
is now dependent onNow we have lint errors. Volume 2 was fixin'. Fixes for lint errors golangci-lint found that are corrected in this PR:
_test.go
files)Finally, time for Return of the King. We then had "just" the fieldalignment optimizations, which have since been re-aligned. For example, here was the suggested output that was since altered