impack

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2023 License: Unlicense Imports: 13 Imported by: 0

README

Impack

Imperfect memory packer for Go

Features

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.

Install

go install github.com/javiercbk/impack/cmd/impack@latest

Usage

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 to gc. Affects the size and the alignment values of types.
  • --arch defaults to amd64. Also affects the size and the alignment values of types.

Documentation

Index

Constants

View Source
const (
	// ErrInvalidCompilerArch is returned when sizes could not be retrieved
	ErrInvalidCompilerArch linterErr = "invalid compiler or architecture"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter performs a simple memory packing on go a package

func NewLinter

func NewLinter(compiler, arch string) (*Linter, error)

NewLinter creates a new ImpackLinter by setting up the sizes and alignments

func (*Linter) Lint

func (linter *Linter) Lint(ctx context.Context, packagePath string) error

Lint finds all structs in a package and lints them

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL