Imperfect memory packer for Go
impack
will grab every struct in a package and order the fields by lower size to higher size. When sizes match it will order alphabetically.
This is an imperfect memory packer since it does not maximize memory efficiency by packing structs perfectly, it attempts to minimize memory footprint but trying to remain as human readable as possible.
go install github.com/javiercbk/impack/cmd/impack@latest
impack
will lint a whole package, and re-order every struct's fields in the package.
impack --compiler gc --arch amd64 /home/user/path/to/go/package/folder1 /home/user/path/to/go/package/folder2
- The first unnammed parameter will be considered as the package path. By default it will be the current folder
--compiler
defaults togc
. Affects the size and the alignment values of types.--arch
defaults toamd64
. Also affects the size and the alignment values of types.