Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

fieldalignment: struct with X pointer bytes could be Y (govet) #220

Closed
atc0005 opened this issue Apr 9, 2021 · 2 comments
Closed

fieldalignment: struct with X pointer bytes could be Y (govet) #220

atc0005 opened this issue Apr 9, 2021 · 2 comments
Assignees
Labels
bug Something isn't working linting

Comments

@atc0005
Copy link
Owner

atc0005 commented Apr 9, 2021

Linting issues exposed by the changes in atc0005/go-ci#287 and atc0005/go-ci#288:

internal/config/types.go:165:12: fieldalignment: struct with 80 pointer bytes could be 64 (govet)
type Email struct {
           ^
internal/config/types.go:269:21: fieldalignment: struct with 296 pointer bytes could be 280 (govet)
type configTemplate struct {
                    ^
internal/events/payload.go:44:14: fieldalignment: struct with 752 pointer bytes could be 744 (govet)
        Result      struct {
                    ^
internal/events/payload.go:168:23: fieldalignment: struct with 152 pointer bytes could be 144 (govet)
type SplunkAlertEvent struct {
                      ^
internal/files/files.go:43:15: fieldalignment: struct with 48 pointer bytes could be 40 (govet)
type FlatFile struct {
              ^
internal/files/files.go:70:20: fieldalignment: struct with 80 pointer bytes could be 72 (govet)
type DisabledUsers struct {
                   ^
internal/files/files.go:96:28: fieldalignment: struct with 96 pointer bytes could be 88 (govet)
type ReportedUserEventsLog struct {
                           ^
cmd/brick/message.go:499:18: fieldalignment: struct with 120 pointer bytes could be 64 (govet)
type emailConfig struct {
                 ^
cmd/brick/message.go:528:10: fieldalignment: struct with 264 pointer bytes could be 256 (govet)
        data := struct {
                ^
cmd/brick/notify.go:35:19: fieldalignment: struct with 32 pointer bytes could be 24 (govet)
type NotifyResult struct {
                  ^
cmd/brick/notify.go:53:18: fieldalignment: struct with 32 pointer bytes could be 24 (govet)
type NotifyQueue struct {
                 ^
@atc0005 atc0005 added bug Something isn't working linting labels Apr 9, 2021
@atc0005 atc0005 added this to the Next Release milestone Apr 9, 2021
@atc0005 atc0005 self-assigned this Apr 9, 2021
@atc0005
Copy link
Owner Author

atc0005 commented Apr 11, 2021

For at least one of the structs I've either found a bug in the fieldalignment linter, or I just don't understand how to properly align the struct.

Reproduced here:

Posted in Gophers Slack to see if anyone can point me in the right direction.

@atc0005
Copy link
Owner Author

atc0005 commented Apr 15, 2021

Never heard back from Twitter or Gophers Slack posts.

Opened an upstream bug report, was kindly told that I misunderstood the problem. Instead of the struct size not being aligned, it was the pointer bytes that the garbage collector had to pass through (paraphrasing) in order to check the struct fields.

The developer of the https://github.com/mdempsky/maligned project has indicated that the "pointer bytes" diagnostic has limited value and should be hidden from users by default.

I'm going to consider this a non-issue for now.

See atc0005/go-ci#302 for more information.

@atc0005 atc0005 closed this as completed Apr 15, 2021
@atc0005 atc0005 removed this from the Next Release milestone Apr 15, 2021
atc0005 added a commit that referenced this issue Apr 15, 2021
Disable govet:fieldalignment, re-enable deprecated maligned
linter until the Go team offers more control over the types
of checks provided by the fieldalignment linter or
golangci-lint does so.

refs GH-218
refs GH-219
refs GH-220
refs atc0005/go-ci#302
atc0005 added a commit that referenced this issue Apr 15, 2021
Disable govet:fieldalignment, re-enable deprecated maligned
linter until the Go team offers more control over the types
of checks provided by the fieldalignment linter or
golangci-lint does so.

- refs GH-218
- refs GH-219
- refs GH-220
- refs atc0005/go-ci#302
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working linting
Projects
None yet
Development

No branches or pull requests

1 participant