
Gost continuously visualizes struct memory layouts, padding gaps and wasted space in real-time, allowing you to optimize your application's memory footprint without ever leaving your editor or saving a file.
Install from the VS Code Marketplace

Why Gost?
In Go, the order of fields in a struct determines its memory footprint. Poorly ordered fields force the Go compiler to introduce "padding" (dead memory space added to align fields with CPU word boundaries), which inflates your app's memory usage and increases Garbage Collection (GC) pressure.
While tools like fieldalignment exist, they are often slow, require saving to disk or only surface as easily-ignored linting warnings.
Gost is different:
- Real-Time Mechanical Sympathy: Visually see the exact byte footprint and memory offsets of your structs as you type.
- Zero Disk I/O: Uses
go/packages.Overlay to map the exact keystrokes of your unsaved VS Code buffer directly into the Go compiler's type-checker in RAM. No temporary files, no waiting on saves.
- Persistent Daemon Architecture: Spawning processes on every keystroke is slow. Gost boots a highly optimized, persistent Go daemon once. It communicates with the JS frontend via lightning-fast Newline-Delimited JSON (NDJSON) over standard I/O streams.
- Geometric Alignment: Automatically calculates visual string widths and injects non-breaking spaces to ensure your right-side memory annotations always form a flawless, readable typography column.
- Zero Setup: The extension bundles cross-compiled binaries for Windows, macOS and Linux. It works out of the box without requiring the Go toolchain to be exposed to your editor environment.
Features & Capabilities
- Live Size & Padding Annotations: See exactly how many bytes each field consumes and exactly how many bytes of padding the compiler is forced to insert after it.
- Wasted Space Detection: Automatically calculates the theoretical minimum size of your struct. If a struct wastes memory, a yellow warning squiggle appears with the exact amount of reclaimable bytes.
- 1-Click Optimization: Click the Optimize CodeLens (or use the native VS Code Quick Fix lightbulb 💡) to instantly rewrite the struct into its mathematically perfect, optimal memory layout order.
- Deep AST Inspection: Flawlessly handles nested anonymous inline structs, accurately calculating memory boundaries without double-counting sizes in the UI.
- Generics Support: Gracefully identifies uninstantiated generic structs (
type Node[T any] struct) and bypasses them without crashing the type-checker.
- Byte Offsets: Optionally display the exact memory offset address (e.g.,
@ 24) for every field in the struct to help visualize cache-line boundaries.
- Ultimate Customizability: Don't like inline comments? Prefer CodeLenses? Want offsets on the left but sizes on the right? The display matrix lets you completely decouple and configure how and where layout data is rendered.
Configuration
You can configure Gost via your VS Code settings.json (also available via the settings UI under Extensions -> Gost).
The display matrix allows you to route any piece of information to either a CodeLens (hovering text above the code), a Decoration (inline virtual formatting) or None.
Display Settings
gost.display.total: How to display the total struct size and wasted space warnings. (Enum: CodeLens, Decoration, None. Default: CodeLens)
gost.display.field: How to display individual field sizes and padding. (Enum: CodeLens, Decoration, None. Default: Decoration)
gost.display.offset: How to display the exact byte memory offset for each field. (Enum: CodeLens, Decoration, None. Default: None)
gost.offset.position: When offsets are grouped with field sizes as decorations, should the offset be placed on the left side (before the field name) or the right side? (Enum: Left, Right. Default: Left)
Commands
Available via the VS Code Command Palette (Ctrl+Shift+P) or natively via Quick Fixes:
- Gost: Optimize Memory Layout: Instantly rewrites the struct currently under your cursor to its most memory-efficient field order.