This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linters-settings: | |
maligned: | |
# print struct with more effective memory layout or not, false by default | |
suggest-new: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ maligned . | |
/Users/rmn/wks/src/github.com/romanitalian/alignment/main.go:8:10: struct of size 12 could be 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ aligncheck . | |
github.com/romanitalian/alignment: /Users/rmn/wks/src/github.com/romanitalian/alignment/main.go:8:6: struct Foo could have size 8 (currently 12) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo struct { | |
aaa [2]bool | |
bbb int32 | |
ccc [2]bool | |
} | |
type Bar struct { | |
aaa [2]bool | |
ccc [2]bool | |
bbb int64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unsafe" | |
) | |
type Foo struct { | |
aaa [2]bool // offset of bytes: 0 | |
bbb int32 // offset of bytes: 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo struct { | |
aaa [2]bool // 2 bytes | |
ccc [2]bool // 2 bytes | |
bbb int32 // 4 bytes | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo struct { | |
aaa [2]bool // 2 bytes | |
bbb int32 // 4 bytes | |
ccc [2]bool // 2 bytes | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo struct { | |
aaa bool | |
bbb int64 | |
ссс bool | |
ddd bool | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo struct { | |
aaa bool // 1 | |
bbb int32 // 4 (max) | |
ссс bool // 1 | |
ddd bool // 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foo2 struct { | |
aaa int32 // 4 | |
bbb int32 // 4 | |
ccc int32 // 4 | |
} |