| 1 | package a |
|---|---|
| 2 | |
| 3 | type Good struct { |
| 4 | y int32 |
| 5 | x byte |
| 6 | z byte |
| 7 | } |
| 8 | |
| 9 | type Bad struct { // want "struct of size 12 could be 8" |
| 10 | x byte |
| 11 | y int32 |
| 12 | z byte |
| 13 | } |
| 14 | |
| 15 | type ZeroGood struct { |
| 16 | a [0]byte |
| 17 | b uint32 |
| 18 | } |
| 19 | |
| 20 | type ZeroBad struct { // want "struct of size 8 could be 4" |
| 21 | a uint32 |
| 22 | b [0]byte |
| 23 | } |
| 24 | |
| 25 | type NoNameGood struct { |
| 26 | Good |
| 27 | y int32 |
| 28 | x byte |
| 29 | z byte |
| 30 | } |
| 31 | |
| 32 | type NoNameBad struct { // want "struct of size 20 could be 16" |
| 33 | Good |
| 34 | x byte |
| 35 | y int32 |
| 36 | z byte |
| 37 | } |
| 38 | |
| 39 | type WithComments struct { // want "struct of size 8 could be 4" |
| 40 | // doc style comment |
| 41 | a uint32 // field a comment |
| 42 | b [0]byte // field b comment |
| 43 | // other doc style comment |
| 44 | |
| 45 | // and a last comment |
| 46 | } |
| 47 |
Members