MCPcopy Index your code
hub / github.com/golang/text

github.com/golang/text @v0.38.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.38.0 ↗ · + Follow
3,772 symbols 13,332 edges 419 files 1,555 documented · 41%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Go Text

Go Reference

This repository holds supplementary Go packages for text processing, many involving Unicode.

CLDR Versioning

It is important that the Unicode version used in x/text matches the one used by your Go compiler. The x/text repository supports multiple versions of Unicode and will match the version of Unicode to that of the Go compiler. At the moment this is supported for Go compilers from version 1.7.

Contribute

To submit changes to this repository, see http://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/text.

To generate the tables in this repository (except for the encoding tables), run go generate from this directory. By default tables are generated for the Unicode version in core and the CLDR version defined in golang.org/x/text/unicode/cldr.

Running go generate will as a side effect create a DATA subdirectory in this directory, which holds all files that are used as a source for generating the tables. This directory will also serve as a cache.

Testing

Run

go test ./...

from this directory to run all tests. Add the "-tags icu" flag to also run ICU conformance tests (if available). This requires that you have the correct ICU version installed on your system.

TODO: - updating unversioned source files.

Generating Tables

To generate the tables in this repository (except for the encoding tables), run go generate from this directory. By default tables are generated for the Unicode version in core and the CLDR version defined in golang.org/x/text/unicode/cldr.

Running go generate will as a side effect create a DATA subdirectory in this directory which holds all files that are used as a source for generating the tables. This directory will also serve as a cache.

Versions

To update a Unicode version run

UNICODE_VERSION=x.x.x go generate

where x.x.x must correspond to a directory in https://www.unicode.org/Public/. If this version is newer than the version in core it will also update the relevant packages there. The idna package in x/net will always be updated.

To update a CLDR version run

CLDR_VERSION=version go generate

where version must correspond to a directory in https://www.unicode.org/Public/cldr/.

Note that the code gets adapted over time to changes in the data and that backwards compatibility is not maintained. So updating to a different version may not work.

The files in DATA/{iana|icu|w3|whatwg} are currently not versioned.

Report Issues

The main issue tracker for the text repository is located at https://go.dev/issues. Prefix your issue with "x/text:" in the subject line, so it is easy to find.

Extension points exported contracts — how you extend this code

Encoding (Interface)
TODO: - There seems to be some inconsistency in when decoders return errors and when not. Also documentation seems to su [8 …
encoding/encoding.go
Transcoder (Interface)
Encoder or Decoder [8 implementers]
encoding/internal/enctest/enctest.go
Namer (Interface)
A Namer is used to get the name for a given value, such as a Tag, Language, Script or Region. [9 implementers]
language/display/display.go
Message (Interface)
A Message holds a collection of translations for the same phrase that may vary based on the values of substitution argum [9 …
internal/catmsg/catmsg.go
Formatter (Interface)
Formatter is analogous to fmt.Formatter. [8 implementers]
internal/format/format.go
Dictionary (Interface)
A Dictionary is a source of translations for a single language. [7 implementers]
message/catalog/catalog.go
Transformer (Interface)
Transformer transforms bytes. [18 implementers]
transform/transform.go
Collator (Interface)
Collator is an interface for architecture-specific implementations of collation. [5 implementers]
collate/tools/colcmp/col.go

Core symbols most depended-on inside this repo

String
called by 355
encoding/internal/enctest/enctest.go
Sprintf
called by 167
message/message.go
Fprintf
called by 166
message/message.go
Printf
called by 165
message/message.go
Println
called by 151
message/message.go
Fprintln
called by 111
message/message.go
Run
called by 102
unicode/bidi/bidi.go
Index
called by 99
unicode/cldr/collate.go

Shape

Function 1,575
Method 1,476
Struct 476
TypeAlias 176
Interface 37
FuncType 32

Languages

Go100%

Modules by API surface

message/fmt_test.go88 symbols
unicode/norm/normalize_test.go80 symbols
internal/language/gen.go64 symbols
language/language.go59 symbols
transform/transform_test.go51 symbols
language/display/display.go49 symbols
internal/export/idna/idna.go48 symbols
unicode/bidi/core.go43 symbols
internal/export/unicode/gen.go41 symbols
message/pipeline/extract.go38 symbols
transform/transform.go36 symbols
unicode/norm/maketables.go35 symbols

For agents

$ claude mcp add text \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact