text/

directory
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0, BSD-3-Clause

README

Frozen x/text runtime

This is the scoped runtime snapshot required by RFC-265. It is not a whole-module fork. Its public entry points are collate, language, transform, and unicode/norm; the remaining packages are their complete non-test x/text dependency closure.

Provenance

  • Source: golang.org/x/text v0.42.0.
  • Upstream Git commit: fafe4a06967e06550e69ee42787d9902845d2a3f.
  • Go module checksum: h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=.
  • Exact module zip SHA-256: a7b64e003056b6470303f408202098d8f3714a115f23091b8cac85edeb265476.
  • SOURCE_SHA256SUMS records the original upstream bytes of every retained source file, LICENSE, and PATENTS. Upstream copyright headers are retained.
Runtime package Go files
collate 5
internal/colltab 8
internal/language 10
internal/language/compact 5
internal/tag 1
language 7
transform 1
unicode/norm 9
Total 46

The collation weights remain upstream UCA 6.2 / CLDR 23 weights. Locale parsing, canonicalization, compact tags, matching, and their tables remain the v0.42.0 implementations; they must not resolve through external x/text packages. The normalization engine is unchanged and uses only the Unicode-15 table.

Original upstream table hashes:

  • collate/tables.go: 470786e0371903f7449b12e261dba458ed3e0c785c95fd3becd7c40864878469 (also the checked-in snapshot hash: no collation data was regenerated).
  • unicode/norm/tables15.0.0.go: 9e29fbffef687d6d2191c999c466729dff2f394d8dcbec377a2fc14336f33cdb (the snapshot removes its compiler-release selector and groups the two recomposition-map variables using the pinned formatter).

Reproducing the import

snapshot.py uses Python's standard library and the repository-pinned mvdan.cc/gofumpt v0.9.2 formatter. It neither downloads inputs nor runs the Go compiler, builds, or tests. Supply the exact module zip or an unpacked v0.42.0 module directory and the pinned formatter executable:

uv run --no-project python internal/unicode15/text/snapshot.py \
  --source /path/to/golang.org/x/text/@v/v0.42.0.zip \
  --gofumpt /path/to/pinned/gofumpt
uv run --no-project python internal/unicode15/text/snapshot.py \
  --source /path/to/golang.org/x/text@v0.42.0 \
  --gofumpt /path/to/pinned/gofumpt --check

The zip form verifies the whole archive hash as well as all 48 per-file hashes. The directory form verifies all 48 per-file hashes. The supplied --gofumpt executable must be built from repository-pinned mvdan.cc/gofumpt v0.9.2 (the Bazel tool). No platform-specific executable hash is required. Every source input is verified, and all Go outputs formatted, before any output is written. All 46 Go files, including generated files, use explicit-file formatting via stdin with -lang=go1.26 -modpath=fdb.dev. This avoids both generated-file skipping and formatter options inferred from the current module or compiler. --check compares all generated bytes without writing and detects formatter output drift. The checked-in script and source manifest define the exact retained file list and transformations; no module download or compiler-selected data is involved. Tests, examples, generator programs, other Unicode-version tables, collate/build, and unrelated module packages are not copied.

This script reproduces the imported upstream table. The parent Unicode-15 UCD generator owns normalization-table regeneration from the pinned UCD inputs; normalization algorithm changes and newer collation weights are out of scope.

Complete local-change inventory

  1. Rewrite quoted golang.org/x/text/... paths, including canonical import comments, to fdb.dev/internal/unicode15/text/... throughout retained Go files. This keeps the entire runtime closure inside the frozen tree.
  2. Remove upstream go:generate directives from collate/collate.go, internal/language/language.go, internal/language/compact/language.go, language/language.go, and unicode/norm/normalize.go. Their programs and tests are not retained; reproduction is through snapshot.py and the parent UCD generator, not upstream generators that may download changing data.
  3. Retain only unicode/norm/tables15.0.0.go and remove its //go:build !go1.27 selector. Do not retain the Unicode-17 table or any other compiler-release table selector.
  4. In internal/colltab/collelem.go, replace the stdlib unicode import and unicode.Is(unicode.Ideographic, r) with the parent Unicode-15 package. Replace the fixed encoding constant unicode.MaxRune with utf8.MaxRune.
  5. In internal/colltab/numeric.go, replace the stdlib unicode import and both unicode.In(r, unicode.Nd) calls with the parent Unicode-15 package.
  6. Replace the three strings.ToLower calls with parent ToLowerString: internal/language/language.go (ParseVariant), internal/language/compact/language.go (Tag.Tag), and language/match.go (region override in Match). This retains simple lowercase, not full casing.
  7. In language/parse.go, replace all four strings.TrimSpace calls in consume and split with a local trimSpace helper. It uses strings.TrimFunc with parent Is(White_Space, r), preserving UTF-8 traversal and malformed-input handling without compiler-dependent whitespace data.
  8. Apply the pinned gofumpt formatter to every retained Go file. Formatting changes eight files: internal/colltab/collelem.go (declaration separation), internal/language/lookup.go (elided redundant map-key literal types), internal/language/compact/tables.go (declaration separation), language/coverage.go (single-variable declaration), language/language.go (trailing blank line), language/parse.go (grouped error variables), language/tables.go (declaration separation and elided redundant array literal types), and unicode/norm/tables15.0.0.go (grouped recompMap and recompMapOnce variables). No table values change.
  9. Replace the four literal interface{} signatures with its exact Go alias any to satisfy the repository's nogo rules: NewCoverage in language/coverage.go, and Compose, CanonType.Compose, and update in language/parse.go. Nonempty interface declarations are unchanged.
  10. In internal/colltab/collelem.go, explicitly type maxUnified, minCompatibility, maxCompatibility, minRare, and maxRare as rune, matching minUnified, to satisfy nogo SA9004. Their literal values and comparisons are unchanged.
  11. In collate/collate.go, remove the empty shifted-handling else branch from Collator.compare to satisfy nogo SA9003. Retain its TODO above the primary comparison. This removes no executable statements.
  12. Add this README, SOURCE_SHA256SUMS, and snapshot.py. Copy upstream LICENSE and PATENTS without modification.

There are no other algorithm or data changes. In particular, stream-safe normalization, malformed-UTF-8 handling, numeric collation's digit handling, implicit weights, locale tables, and collation options retain upstream logic.

Unicode-data dependency inventory

All Unicode-dependent runtime lookups outside the retained normalization and collation/locale tables now use fdb.dev/internal/unicode15:

Source site Frozen API
internal/colltab/collelem.go, implicit ideographic weight Is(Ideographic, r)
internal/colltab/numeric.go, two digit classifiers In(r, Nd)
internal/language/language.go, variant parsing ToLowerString(s)
internal/language/compact/language.go, region override ToLowerString(s)
language/match.go, region override ToLowerString(s)
language/parse.go, Accept-Language whitespace Is(White_Space, r)

The parent must supply Is(*RangeTable, rune) bool, In(rune, ...*RangeTable) bool, Ideographic, Nd, White_Space, and ToLowerString(string) string. The snapshot has no remaining direct stdlib unicode import, strings.ToLower/ToUpper/EqualFold call, or strings.TrimSpace call. The retained unicode/utf8 operations and constants, byte comparisons, byte-indexed locale parsing, and strings.TrimFunc traversal are fixed encoding mechanics, not host Unicode-data lookups.

Runtime/compiler verification is a separate RFC gate. Reproducing these files or finding no forbidden imports is not a claim of behavioral equivalence.

Directories

Path Synopsis
Package collate contains types for comparing and sorting Unicode strings according to a given collation order.
Package collate contains types for comparing and sorting Unicode strings according to a given collation order.
internal
colltab
Package colltab contains functionality related to collation tables.
Package colltab contains functionality related to collation tables.
language/compact
Package compact defines a compact representation of language tags.
Package compact defines a compact representation of language tags.
tag
Package tag contains functionality handling tags and related data.
Package tag contains functionality handling tags and related data.
Package language implements BCP 47 language tags and related functionality.
Package language implements BCP 47 language tags and related functionality.
Package transform provides reader and writer wrappers that transform the bytes passing through as well as various transformations.
Package transform provides reader and writer wrappers that transform the bytes passing through as well as various transformations.
unicode
norm
Package norm contains types and functions for normalizing Unicode strings.
Package norm contains types and functions for normalizing Unicode strings.

Jump to

Keyboard shortcuts

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