Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ddec15

Browse files
committed
language: use internal/language/compact
This exposes all the internal compact IDs within x/text but not outside. Change-Id: I3c5e63f26a3e2774e70fdb48390522f444a850ae Reviewed-on: https://go-review.googlesource.com/96639 Run-TryBot: Marcel van Lohuizen <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ross Light <[email protected]>
1 parent b7ef84a commit 6ddec15

File tree

9 files changed

+120
-1504
lines changed

9 files changed

+120
-1504
lines changed

internal/language/compact/language.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
// specific language or locale. All language tag values are guaranteed to be
2020
// well-formed.
2121
type Tag struct {
22+
// NOTE: exported tags will become part of the public API.
2223
language ID
2324
locale ID
2425
full fullTag // always a language.Tag for now.
@@ -135,9 +136,6 @@ func LanguageID(t Tag) (id ID, exact bool) {
135136
return t.language, t.full == nil
136137
}
137138

138-
// TODO: make these functions and methods public once we settle on the API and
139-
//
140-
141139
// RegionalID returns the ID for the regional variant of this tag. This index is
142140
// used to indicate region-specific overrides, such as default currency, default
143141
// calendar and week data, default time cycle, and default measurement system

internal/language/compact/language_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ func TestTagSize(t *testing.T) {
2727
}
2828
}
2929

30+
func TestNoPublic(t *testing.T) {
31+
noExportedField(t, reflect.TypeOf(Tag{}))
32+
}
33+
34+
func noExportedField(t *testing.T, typ reflect.Type) {
35+
for i := 0; i < typ.NumField(); i++ {
36+
f := typ.Field(i)
37+
if f.PkgPath == "" {
38+
t.Errorf("Tag may not have exported fields, but has field %q", f.Name)
39+
}
40+
if f.Anonymous {
41+
noExportedField(t, f.Type)
42+
}
43+
}
44+
}
45+
3046
func TestEquality(t *testing.T) {
3147
for i, tt := range parseTests() {
3248
s := tt.in

language/compact.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

language/gen.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@ func main() {
3838
w := gen.NewCodeWriter()
3939
defer w.WriteGoFile("tables.go", "language")
4040

41-
fmt.Fprintln(w, `import "golang.org/x/text/internal/language"`)
42-
4341
b := newBuilder(w)
4442
gen.WriteCLDRVersion(w)
4543

4644
b.writeConstants()
47-
b.writeCompactIndex()
4845
b.writeMatchData()
4946
}
5047

language/gen_index.go

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)