Skip to content

devasherr/gpad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpad

gpad is a Go CLI Tool that automatically reorders struct fileds across your codebase to optimize memory layout and reduce padding. It helps improve memory efficiency in Go programs by analyzing structs and rearranging fields for better alignment.

Installation

Install gpad using go install:

go install github.com/devasherr/gpad@v0.1.2

Usage

After installation, run gpad from the root of your Go project:

gpad

Thats it, all structs in the codebase have been sorted!!

  • You can also specify a custom directory to start from using the -path flag:
gpad -path "/internal/models"

This will only process structs within the specified directory and its subdirectories

  • If you want more details you can run the tool in verbose mode:
gpad -path "/internal/models" -v
Metric Value
Time Taken: 6.370862ms
Initial Allocation: 128 bytes
Current Allocation: 112 bytes
Saved: 16 bytes (12.50%)

About

Struct Padding Optimizer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages