| 1 |
# Go Text |
| 2 |
|
| 3 |
[](https://pkg.go.dev/golang.org/x/text) |
| 4 |
|
| 5 |
This repository holds supplementary Go packages for text processing, |
| 6 |
many involving Unicode. |
| 7 |
|
| 8 |
## CLDR Versioning |
| 9 |
|
| 10 |
It is important that the Unicode version used in `x/text` matches the one used |
| 11 |
by your Go compiler. The `x/text` repository supports multiple versions of |
| 12 |
Unicode and will match the version of Unicode to that of the Go compiler. At the |
| 13 |
moment this is supported for Go compilers from version 1.7. |
| 14 |
|
| 15 |
## Contribute |
| 16 |
|
| 17 |
To submit changes to this repository, see http://go.dev/doc/contribute. |
| 18 |
|
| 19 |
The git repository is https://go.googlesource.com/text. |
| 20 |
|
| 21 |
To generate the tables in this repository (except for the encoding tables), |
| 22 |
run go generate from this directory. By default tables are generated for the |
| 23 |
Unicode version in core and the CLDR version defined in |
| 24 |
golang.org/x/text/unicode/cldr. |
| 25 |
|
| 26 |
Running go generate will as a side effect create a DATA subdirectory in this |
| 27 |
directory, which holds all files that are used as a source for generating the |
| 28 |
tables. This directory will also serve as a cache. |
| 29 |
|
| 30 |
## Testing |
| 31 |
|
| 32 |
Run |
| 33 |
|
| 34 |
go test ./... |
| 35 |
|
| 36 |
from this directory to run all tests. Add the "-tags icu" flag to also run |
| 37 |
ICU conformance tests (if available). This requires that you have the correct |
| 38 |
ICU version installed on your system. |
| 39 |
|
| 40 |
TODO: |
| 41 |
- updating unversioned source files. |
| 42 |
|
| 43 |
## Generating Tables |
| 44 |
|
| 45 |
To generate the tables in this repository (except for the encoding |
| 46 |
tables), run `go generate` from this directory. By default tables are |
| 47 |
generated for the Unicode version in core and the CLDR version defined in |
| 48 |
golang.org/x/text/unicode/cldr. |
| 49 |
|
| 50 |
Running go generate will as a side effect create a DATA subdirectory in this |
| 51 |
directory which holds all files that are used as a source for generating the |
| 52 |
tables. This directory will also serve as a cache. |
| 53 |
|
| 54 |
## Versions |
| 55 |
|
| 56 |
To update a Unicode version run |
| 57 |
|
| 58 |
UNICODE_VERSION=x.x.x go generate |
| 59 |
|
| 60 |
where `x.x.x` must correspond to a directory in https://www.unicode.org/Public/. |
| 61 |
If this version is newer than the version in core it will also update the |
| 62 |
relevant packages there. The idna package in x/net will always be updated. |
| 63 |
|
| 64 |
To update a CLDR version run |
| 65 |
|
| 66 |
CLDR_VERSION=version go generate |
| 67 |
|
| 68 |
where `version` must correspond to a directory in |
| 69 |
https://www.unicode.org/Public/cldr/. |
| 70 |
|
| 71 |
Note that the code gets adapted over time to changes in the data and that |
| 72 |
backwards compatibility is not maintained. |
| 73 |
So updating to a different version may not work. |
| 74 |
|
| 75 |
The files in DATA/{iana|icu|w3|whatwg} are currently not versioned. |
| 76 |
|
| 77 |
## Report Issues |
| 78 |
|
| 79 |
The main issue tracker for the text repository is located at |
| 80 |
https://go.dev/issues. Prefix your issue with "x/text:" in the |
| 81 |
subject line, so it is easy to find. |