What version of Go are you using (go version)?
$ go version
go version go1.16.3 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\atc0005\AppData\Local\go-build
set GOENV=C:\Users\atc0005\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\atc0005\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\atc0005\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=T:\github\help-requests\go\struct-alignment\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\atc0005\AppData\Local\Temp\go-build4294469141=/tmp/go-build -gno-record-gcc-switches
What did you do?
Example structs:
type emailConfigAscending struct {
timeout time.Duration // 8 bytes
notificationRateLimit time.Duration // 8 bytes
template *template.Template // 8 bytes
serverPort int // 8 bytes
notificationRetries int // 8 bytes
notificationRetryDelay int // 8 bytes
server string // 16 bytes
senderAddress string // 16 bytes
clientIdentity string // 16 bytes
recipientAddresses []string // 24 bytes
}
type emailConfigDescending struct {
recipientAddresses []string // 24 bytes
server string // 16 bytes
senderAddress string // 16 bytes
clientIdentity string // 16 bytes
timeout time.Duration // 8 bytes
notificationRateLimit time.Duration // 8 bytes
template *template.Template // 8 bytes
serverPort int // 8 bytes
notificationRetries int // 8 bytes
notificationRetryDelay int // 8 bytes
}
I first encountered the linting errors via CI Docker container (govet fieldalignment golangci-lint linter), then reproduced by enabling fieldalignment vscode Go plugin analyzer.
What did you expect to see?
No linting errors.
What did you see instead?
These linting errors for two variations of the struct:
- fieldalignment: struct with 104 pointer bytes could be 64 (govet)
- fieldalignment: struct with 96 pointer bytes could be 64 (govet)
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
Example structs:
I first encountered the linting errors via CI Docker container (govet
fieldalignmentgolangci-lint linter), then reproduced by enablingfieldalignmentvscode Go plugin analyzer.fieldalignmentlinterWhat did you expect to see?
No linting errors.
What did you see instead?
These linting errors for two variations of the struct: