minify

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package minify produces a denser, token-cheaper VIEW of a source file for read-only exploration. It strips comments and redundant whitespace so the model can scan or understand code for far fewer tokens than read_file's raw, line-numbered output — without ever changing the file on disk.

Correctness over aggression: Go is minified through the real go/parser AST (guaranteed valid, comment-free output), and any file it cannot parse — or any non-Go file — falls back to a conservative whitespace normalization that can never alter code meaning (it strips no comments, since doing that safely needs a real parser per language). The transform is therefore incapable of corrupting what the model sees: the worst case is "no reduction", never "wrong content".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Content  string // minified (or whitespace-normalized) text; never line-numbered
	Language string // strategy taken: "go" or "text"
	Applied  bool   // true only when real comment-stripping minification ran
}

Result is the outcome of minifying one file's bytes.

func ContextualFragment

func ContextualFragment(path string, source, content []byte, startOffset int) Result

ContextualFragment minifies a bounded fragment after checking its starting position against the complete source. A Go range that begins inside a string or comment must remain verbatim apart from whitespace normalization: parsing that fragment by itself would mistake literal text for Go syntax.

func File

func File(path string, content []byte) Result

File minifies content addressed by path; the extension selects the strategy.

func Fragment

func Fragment(path string, content []byte) Result

Fragment minifies a bounded source range without assuming lexical state from text outside the range. Go remains parser-validated; other languages use the conservative whitespace-only transform because a range may begin inside a multiline string or block comment.

Jump to

Keyboard shortcuts

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