Help us shape the future of Go! Take the 2026 Go Developer Survey

normalize

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package normalize provides the shared content-normalization rule used to compute Båge's normalized content hash. The rule is byte-identical with Hylla's so the two systems agree on whitespace-only drift classification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(b []byte) []byte

Normalize applies Båge's canonical content-normalization rule and returns a newly allocated slice; the input is never mutated. The rule, in order:

  1. normalize line endings to LF by dropping every carriage return (\r);
  2. strip trailing horizontal whitespace ([ \t\r]) immediately before each LF and at end-of-input;
  3. strip ALL consecutive leading UTF-8 BOMs (0xEF 0xBB 0xBF) — LAST.

It is a pure function with no I/O. Interior whitespace (including tabs) is preserved byte-for-byte. The ORDER is load-bearing for idempotency (and region_hash stability across systems): BOM stripping runs last, on the CR-free output, so a \r embedded in a BOM byte run cannot re-form a leading BOM after the strip; and ALL leading BOMs are stripped, not just one. Both are fuzz-discovered invariants (FuzzNormalizeIdempotent) — Hylla MUST match.

Types

This section is empty.

Jump to

Keyboard shortcuts

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