Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
544de19c
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
544de19c
编写于
4月 27, 2019
作者:
T
Thomas Strömberg
提交者:
GitHub
4月 27, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4165 from sharifelgamal/number-format
Do not use separators when printing numbers
上级
17f6ffe5
31a4e9e6
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
17087 addition
and
32 deletion
+17087
-32
Gopkg.lock
Gopkg.lock
+5
-3
Gopkg.toml
Gopkg.toml
+1
-1
pkg/minikube/console/console_test.go
pkg/minikube/console/console_test.go
+3
-1
pkg/minikube/console/style.go
pkg/minikube/console/style.go
+6
-0
vendor/golang.org/x/text/internal/gen/code.go
vendor/golang.org/x/text/internal/gen/code.go
+6
-2
vendor/golang.org/x/text/internal/gen/gen.go
vendor/golang.org/x/text/internal/gen/gen.go
+33
-19
vendor/golang.org/x/text/internal/number/roundingmode_string.go
.../golang.org/x/text/internal/number/roundingmode_string.go
+14
-0
vendor/golang.org/x/text/language/language.go
vendor/golang.org/x/text/language/language.go
+1
-1
vendor/golang.org/x/text/number/doc.go
vendor/golang.org/x/text/number/doc.go
+28
-0
vendor/golang.org/x/text/number/format.go
vendor/golang.org/x/text/number/format.go
+122
-0
vendor/golang.org/x/text/number/number.go
vendor/golang.org/x/text/number/number.go
+77
-0
vendor/golang.org/x/text/number/option.go
vendor/golang.org/x/text/number/option.go
+177
-0
vendor/golang.org/x/text/transform/transform.go
vendor/golang.org/x/text/transform/transform.go
+1
-1
vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go
vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go
+1
-1
vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go
vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go
+1887
-0
vendor/golang.org/x/text/unicode/cldr/cldr.go
vendor/golang.org/x/text/unicode/cldr/cldr.go
+1
-1
vendor/golang.org/x/text/unicode/norm/tables10.0.0.go
vendor/golang.org/x/text/unicode/norm/tables10.0.0.go
+1
-1
vendor/golang.org/x/text/unicode/norm/tables11.0.0.go
vendor/golang.org/x/text/unicode/norm/tables11.0.0.go
+7693
-0
vendor/golang.org/x/text/unicode/rangetable/tables10.0.0.go
vendor/golang.org/x/text/unicode/rangetable/tables10.0.0.go
+1
-1
vendor/golang.org/x/text/unicode/rangetable/tables11.0.0.go
vendor/golang.org/x/text/unicode/rangetable/tables11.0.0.go
+7029
-0
未找到文件。
Gopkg.lock
浏览文件 @
544de19c
...
@@ -695,8 +695,7 @@
...
@@ -695,8 +695,7 @@
revision = "95c6576299259db960f6c5b9b69ea52422860fce"
revision = "95c6576299259db960f6c5b9b69ea52422860fce"
[[projects]]
[[projects]]
branch = "master"
digest = "1:2780cbd603ca1ee6f33330fb3a590ebaea0e95b99c7759f4d17e2337cca9352a"
digest = "1:11d290de3457882172ce8d9ffe930999cfb62929b58e486e1ff1b6adcf3c52bc"
name = "golang.org/x/text"
name = "golang.org/x/text"
packages = [
packages = [
"collate",
"collate",
...
@@ -717,6 +716,7 @@
...
@@ -717,6 +716,7 @@
"language",
"language",
"message",
"message",
"message/catalog",
"message/catalog",
"number",
"secure/bidirule",
"secure/bidirule",
"transform",
"transform",
"unicode/bidi",
"unicode/bidi",
...
@@ -725,7 +725,7 @@
...
@@ -725,7 +725,7 @@
"unicode/rangetable",
"unicode/rangetable",
]
]
pruneopts = "NUT"
pruneopts = "NUT"
revision = "
e6919f6577db79269a6443b9dc46d18f2238fb5d
"
revision = "
342b2e1fbaa52c93f31447ad2c6abc048c63e475
"
[[projects]]
[[projects]]
digest = "1:d37b0ef2944431fe9e8ef35c6fffc8990d9e2ca300588df94a6890f3649ae365"
digest = "1:d37b0ef2944431fe9e8ef35c6fffc8990d9e2ca300588df94a6890f3649ae365"
...
@@ -1035,6 +1035,7 @@
...
@@ -1035,6 +1035,7 @@
"golang.org/x/sys/windows/registry",
"golang.org/x/sys/windows/registry",
"golang.org/x/text/language",
"golang.org/x/text/language",
"golang.org/x/text/message",
"golang.org/x/text/message",
"golang.org/x/text/number",
"k8s.io/api/apps/v1",
"k8s.io/api/apps/v1",
"k8s.io/api/core/v1",
"k8s.io/api/core/v1",
"k8s.io/api/rbac/v1beta1",
"k8s.io/api/rbac/v1beta1",
...
@@ -1046,6 +1047,7 @@
...
@@ -1046,6 +1047,7 @@
"k8s.io/apimachinery/pkg/runtime",
"k8s.io/apimachinery/pkg/runtime",
"k8s.io/apimachinery/pkg/runtime/schema",
"k8s.io/apimachinery/pkg/runtime/schema",
"k8s.io/apimachinery/pkg/types",
"k8s.io/apimachinery/pkg/types",
"k8s.io/apimachinery/pkg/util/intstr",
"k8s.io/apimachinery/pkg/util/net",
"k8s.io/apimachinery/pkg/util/net",
"k8s.io/apimachinery/pkg/util/strategicpatch",
"k8s.io/apimachinery/pkg/util/strategicpatch",
"k8s.io/apimachinery/pkg/util/uuid",
"k8s.io/apimachinery/pkg/util/uuid",
...
...
Gopkg.toml
浏览文件 @
544de19c
...
@@ -117,4 +117,4 @@
...
@@ -117,4 +117,4 @@
[[constraint]]
[[constraint]]
name
=
"golang.org/x/text"
name
=
"golang.org/x/text"
branch
=
"master
"
revision
=
"342b2e1fbaa52c93f31447ad2c6abc048c63e475
"
pkg/minikube/console/console_test.go
浏览文件 @
544de19c
...
@@ -75,6 +75,8 @@ func TestOutStyle(t *testing.T) {
...
@@ -75,6 +75,8 @@ func TestOutStyle(t *testing.T) {
[]
interface
{}{
"encode '%' signs"
,
"%s%%%d"
},
[]
interface
{}{
"encode '%' signs"
,
"%s%%%d"
},
" - Message with params: encode '%' signs %s%%%d
\n
"
,
" - Message with params: encode '%' signs %s%%%d
\n
"
,
},
},
{
"issue"
,
"true"
,
"No separators for long ints: %d"
,
[]
interface
{}{
10000
},
" ▪ No separators for long ints: 10000
\n
"
},
{
"issue"
,
"false"
,
"No separators for long ints: %d"
,
[]
interface
{}{
5000
},
" - No separators for long ints: 5000
\n
"
},
}
}
for
_
,
tc
:=
range
tests
{
for
_
,
tc
:=
range
tests
{
t
.
Run
(
tc
.
style
+
"-"
+
tc
.
envValue
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tc
.
style
+
"-"
+
tc
.
envValue
,
func
(
t
*
testing
.
T
)
{
...
@@ -103,7 +105,7 @@ func TestOut(t *testing.T) {
...
@@ -103,7 +105,7 @@ func TestOut(t *testing.T) {
var
tests
=
[]
struct
{
var
tests
=
[]
struct
{
format
string
format
string
lang
language
.
Tag
lang
language
.
Tag
arg
string
arg
interface
{}
want
string
want
string
}{
}{
{
format
:
"xyz123"
,
want
:
"xyz123"
},
{
format
:
"xyz123"
,
want
:
"xyz123"
},
...
...
pkg/minikube/console/style.go
浏览文件 @
544de19c
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"strings"
"strings"
"golang.org/x/text/message"
"golang.org/x/text/message"
"golang.org/x/text/number"
)
)
var
(
var
(
...
@@ -131,6 +132,11 @@ func lowPrefix(s style) string {
...
@@ -131,6 +132,11 @@ func lowPrefix(s style) string {
// Apply styling to a format string
// Apply styling to a format string
func
applyStyle
(
style
string
,
useColor
bool
,
format
string
,
a
...
interface
{})
(
string
,
error
)
{
func
applyStyle
(
style
string
,
useColor
bool
,
format
string
,
a
...
interface
{})
(
string
,
error
)
{
p
:=
message
.
NewPrinter
(
preferredLanguage
)
p
:=
message
.
NewPrinter
(
preferredLanguage
)
for
i
,
x
:=
range
a
{
if
_
,
ok
:=
x
.
(
int
);
ok
{
a
[
i
]
=
number
.
Decimal
(
x
,
number
.
NoSeparator
())
}
}
out
:=
p
.
Sprintf
(
format
,
a
...
)
out
:=
p
.
Sprintf
(
format
,
a
...
)
s
,
ok
:=
styles
[
style
]
s
,
ok
:=
styles
[
style
]
...
...
vendor/golang.org/x/text/internal/gen/code.go
浏览文件 @
544de19c
...
@@ -66,7 +66,9 @@ func (w *CodeWriter) WriteGoFile(filename, pkg string) {
...
@@ -66,7 +66,9 @@ func (w *CodeWriter) WriteGoFile(filename, pkg string) {
func
(
w
*
CodeWriter
)
WriteVersionedGoFile
(
filename
,
pkg
string
)
{
func
(
w
*
CodeWriter
)
WriteVersionedGoFile
(
filename
,
pkg
string
)
{
tags
:=
buildTags
()
tags
:=
buildTags
()
if
tags
!=
""
{
if
tags
!=
""
{
filename
=
insertVersion
(
filename
,
UnicodeVersion
())
pattern
:=
fileToPattern
(
filename
)
updateBuildTags
(
pattern
)
filename
=
fmt
.
Sprintf
(
pattern
,
UnicodeVersion
())
}
}
f
,
err
:=
os
.
Create
(
filename
)
f
,
err
:=
os
.
Create
(
filename
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -82,7 +84,9 @@ func (w *CodeWriter) WriteVersionedGoFile(filename, pkg string) {
...
@@ -82,7 +84,9 @@ func (w *CodeWriter) WriteVersionedGoFile(filename, pkg string) {
// writes it as a Go file to the given writer with the given package name.
// writes it as a Go file to the given writer with the given package name.
func
(
w
*
CodeWriter
)
WriteGo
(
out
io
.
Writer
,
pkg
,
tags
string
)
(
n
int
,
err
error
)
{
func
(
w
*
CodeWriter
)
WriteGo
(
out
io
.
Writer
,
pkg
,
tags
string
)
(
n
int
,
err
error
)
{
sz
:=
w
.
Size
sz
:=
w
.
Size
w
.
WriteComment
(
"Total table size %d bytes (%dKiB); checksum: %X
\n
"
,
sz
,
sz
/
1024
,
w
.
Hash
.
Sum32
())
if
sz
>
0
{
w
.
WriteComment
(
"Total table size %d bytes (%dKiB); checksum: %X
\n
"
,
sz
,
sz
/
1024
,
w
.
Hash
.
Sum32
())
}
defer
w
.
buf
.
Reset
()
defer
w
.
buf
.
Reset
()
return
WriteGo
(
out
,
pkg
,
tags
,
w
.
buf
.
Bytes
())
return
WriteGo
(
out
,
pkg
,
tags
,
w
.
buf
.
Bytes
())
}
}
...
...
vendor/golang.org/x/text/internal/gen/gen.go
浏览文件 @
544de19c
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"os"
"os"
"path"
"path"
"path/filepath"
"path/filepath"
"regexp"
"strings"
"strings"
"sync"
"sync"
"unicode"
"unicode"
...
@@ -83,25 +84,21 @@ func CLDRVersion() string {
...
@@ -83,25 +84,21 @@ func CLDRVersion() string {
}
}
var
tags
=
[]
struct
{
version
,
buildTags
string
}{
var
tags
=
[]
struct
{
version
,
buildTags
string
}{
{
"10.0.0"
,
"go1.10"
},
{
"9.0.0"
,
"!go1.10"
},
{
""
,
"!go1.10"
},
{
"10.0.0"
,
"go1.10,!go1.13"
},
{
"11.0.0"
,
"go1.13"
},
}
}
// buildTags reports the build tags used for the current Unicode version.
// buildTags reports the build tags used for the current Unicode version.
func
buildTags
()
string
{
func
buildTags
()
string
{
v
:=
UnicodeVersion
()
v
:=
UnicodeVersion
()
for
_
,
x
:=
range
tags
{
for
_
,
e
:=
range
tags
{
// We should do a numeric comparison, but including the collate package
if
e
.
version
==
v
{
// would create an import cycle. We approximate it by assuming that
return
e
.
buildTags
// longer version strings are later.
if
len
(
x
.
version
)
<=
len
(
v
)
{
return
x
.
buildTags
}
if
len
(
x
.
version
)
==
len
(
v
)
&&
x
.
version
<=
v
{
return
x
.
buildTags
}
}
}
}
return
tags
[
0
]
.
buildTags
log
.
Fatalf
(
"Unknown build tags for Unicode version %q."
,
v
)
return
""
}
}
// IsLocal reports whether data files are available locally.
// IsLocal reports whether data files are available locally.
...
@@ -269,12 +266,29 @@ func WriteGoFile(filename, pkg string, b []byte) {
...
@@ -269,12 +266,29 @@ func WriteGoFile(filename, pkg string, b []byte) {
}
}
}
}
func
insertVersion
(
filename
,
version
string
)
string
{
func
fileToPattern
(
filename
string
)
string
{
suffix
:=
".go"
suffix
:=
".go"
if
strings
.
HasSuffix
(
filename
,
"_test.go"
)
{
if
strings
.
HasSuffix
(
filename
,
"_test.go"
)
{
suffix
=
"_test.go"
suffix
=
"_test.go"
}
}
return
fmt
.
Sprint
(
filename
[
:
len
(
filename
)
-
len
(
suffix
)],
version
,
suffix
)
prefix
:=
filename
[
:
len
(
filename
)
-
len
(
suffix
)]
return
fmt
.
Sprint
(
prefix
,
"%s"
,
suffix
)
}
func
updateBuildTags
(
pattern
string
)
{
for
_
,
t
:=
range
tags
{
oldFile
:=
fmt
.
Sprintf
(
pattern
,
t
.
version
)
b
,
err
:=
ioutil
.
ReadFile
(
oldFile
)
if
err
!=
nil
{
continue
}
build
:=
fmt
.
Sprintf
(
"// +build %s"
,
t
.
buildTags
)
b
=
regexp
.
MustCompile
(
`// \+build .*`
)
.
ReplaceAll
(
b
,
[]
byte
(
build
))
err
=
ioutil
.
WriteFile
(
oldFile
,
b
,
0644
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
}
}
// WriteVersionedGoFile prepends a standard file comment, adds build tags to
// WriteVersionedGoFile prepends a standard file comment, adds build tags to
...
@@ -282,16 +296,16 @@ func insertVersion(filename, version string) string {
...
@@ -282,16 +296,16 @@ func insertVersion(filename, version string) string {
// the given bytes, applies gofmt, and writes them to a file with the given
// the given bytes, applies gofmt, and writes them to a file with the given
// name. It will call log.Fatal if there are any errors.
// name. It will call log.Fatal if there are any errors.
func
WriteVersionedGoFile
(
filename
,
pkg
string
,
b
[]
byte
)
{
func
WriteVersionedGoFile
(
filename
,
pkg
string
,
b
[]
byte
)
{
tags
:=
buildTags
(
)
pattern
:=
fileToPattern
(
filename
)
if
tags
!=
""
{
updateBuildTags
(
pattern
)
filename
=
insertVersion
(
filename
,
UnicodeVersion
())
filename
=
fmt
.
Sprintf
(
pattern
,
UnicodeVersion
())
}
w
,
err
:=
os
.
Create
(
filename
)
w
,
err
:=
os
.
Create
(
filename
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"Could not create file %s: %v"
,
filename
,
err
)
log
.
Fatalf
(
"Could not create file %s: %v"
,
filename
,
err
)
}
}
defer
w
.
Close
()
defer
w
.
Close
()
if
_
,
err
=
WriteGo
(
w
,
pkg
,
tags
,
b
);
err
!=
nil
{
if
_
,
err
=
WriteGo
(
w
,
pkg
,
buildTags
()
,
b
);
err
!=
nil
{
log
.
Fatalf
(
"Error writing file %s: %v"
,
filename
,
err
)
log
.
Fatalf
(
"Error writing file %s: %v"
,
filename
,
err
)
}
}
}
}
...
...
vendor/golang.org/x/text/internal/number/roundingmode_string.go
浏览文件 @
544de19c
...
@@ -4,6 +4,20 @@ package number
...
@@ -4,6 +4,20 @@ package number
import
"strconv"
import
"strconv"
func
_
()
{
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var
x
[
1
]
struct
{}
_
=
x
[
ToNearestEven
-
0
]
_
=
x
[
ToNearestZero
-
1
]
_
=
x
[
ToNearestAway
-
2
]
_
=
x
[
ToPositiveInf
-
3
]
_
=
x
[
ToNegativeInf
-
4
]
_
=
x
[
ToZero
-
5
]
_
=
x
[
AwayFromZero
-
6
]
_
=
x
[
numModes
-
7
]
}
const
_RoundingMode_name
=
"ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes"
const
_RoundingMode_name
=
"ToNearestEvenToNearestZeroToNearestAwayToPositiveInfToNegativeInfToZeroAwayFromZeronumModes"
var
_RoundingMode_index
=
[
...
]
uint8
{
0
,
13
,
26
,
39
,
52
,
65
,
71
,
83
,
91
}
var
_RoundingMode_index
=
[
...
]
uint8
{
0
,
13
,
26
,
39
,
52
,
65
,
71
,
83
,
91
}
...
...
vendor/golang.org/x/text/language/language.go
浏览文件 @
544de19c
...
@@ -530,7 +530,7 @@ func (r Region) String() string {
...
@@ -530,7 +530,7 @@ func (r Region) String() string {
// Note that not all regions have a 3-letter ISO code.
// Note that not all regions have a 3-letter ISO code.
// In such cases this method returns "ZZZ".
// In such cases this method returns "ZZZ".
func
(
r
Region
)
ISO3
()
string
{
func
(
r
Region
)
ISO3
()
string
{
return
r
.
regionID
.
String
()
return
r
.
regionID
.
ISO3
()
}
}
// M49 returns the UN M.49 encoding of r, or 0 if this encoding
// M49 returns the UN M.49 encoding of r, or 0 if this encoding
...
...
vendor/golang.org/x/text/number/doc.go
0 → 100644
浏览文件 @
544de19c
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package number formats numbers according to the customs of different locales.
//
// The number formats of this package allow for greater formatting flexibility
// than passing values to message.Printf calls as is. It currently supports the
// builtin Go types and anything that implements the Convert interface
// (currently internal).
//
// p := message.NewPrinter(language.English)
//
// p.Printf("%v bottles of beer on the wall.", number.Decimal(1234))
// // Prints: 1,234 bottles of beer on the wall.
//
// p.Printf("%v of gophers lose too much fur", number.Percent(0.12))
// // Prints: 12% of gophers lose too much fur.
//
// p := message.NewPrinter(language.Dutch)
//
// p.Printf("There are %v bikes per household.", number.Decimal(1.2))
// // Prints: Er zijn 1,2 fietsen per huishouden.
//
//
// The width and scale specified in the formatting directives override the
// configuration of the formatter.
package
number
vendor/golang.org/x/text/number/format.go
0 → 100644
浏览文件 @
544de19c
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
number
import
(
"fmt"
"strings"
"golang.org/x/text/feature/plural"
"golang.org/x/text/internal/format"
"golang.org/x/text/internal/number"
"golang.org/x/text/language"
)
// A FormatFunc formates a number.
type
FormatFunc
func
(
x
interface
{},
opts
...
Option
)
Formatter
// NewFormat creates a FormatFunc based on another FormatFunc and new options.
// Use NewFormat to cash the creation of formatters.
func
NewFormat
(
format
FormatFunc
,
opts
...
Option
)
FormatFunc
{
o
:=
*
format
(
nil
)
.
options
n
:=
len
(
o
.
options
)
o
.
options
=
append
(
o
.
options
[
:
n
:
n
],
opts
...
)
return
func
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
&
o
,
opts
,
x
)
}
}
type
options
struct
{
verbs
string
initFunc
initFunc
options
[]
Option
pluralFunc
func
(
t
language
.
Tag
,
scale
int
)
(
f
plural
.
Form
,
n
int
)
}
type
optionFlag
uint16
const
(
hasScale
optionFlag
=
1
<<
iota
hasPrecision
noSeparator
exact
)
type
initFunc
func
(
f
*
number
.
Formatter
,
t
language
.
Tag
)
func
newFormatter
(
o
*
options
,
opts
[]
Option
,
value
interface
{})
Formatter
{
if
len
(
opts
)
>
0
{
n
:=
*
o
n
.
options
=
opts
o
=
&
n
}
return
Formatter
{
o
,
value
}
}
func
newOptions
(
verbs
string
,
f
initFunc
)
*
options
{
return
&
options
{
verbs
:
verbs
,
initFunc
:
f
}
}
type
Formatter
struct
{
*
options
value
interface
{}
}
// Format implements format.Formatter. It is for internal use only for now.
func
(
f
Formatter
)
Format
(
state
format
.
State
,
verb
rune
)
{
// TODO: consider implementing fmt.Formatter instead and using the following
// piece of code. This allows numbers to be rendered mostly as expected
// when using fmt. But it may get weird with the spellout options and we
// may need more of format.State over time.
// lang := language.Und
// if s, ok := state.(format.State); ok {
// lang = s.Language()
// }
lang
:=
state
.
Language
()
if
!
strings
.
Contains
(
f
.
verbs
,
string
(
verb
))
{
fmt
.
Fprintf
(
state
,
"%%!%s(%T=%v)"
,
string
(
verb
),
f
.
value
,
f
.
value
)
return
}
var
p
number
.
Formatter
f
.
initFunc
(
&
p
,
lang
)
for
_
,
o
:=
range
f
.
options
.
options
{
o
(
lang
,
&
p
)
}
if
w
,
ok
:=
state
.
Width
();
ok
{
p
.
FormatWidth
=
uint16
(
w
)
}
if
prec
,
ok
:=
state
.
Precision
();
ok
{
switch
verb
{
case
'd'
:
p
.
SetScale
(
0
)
case
'f'
:
p
.
SetScale
(
prec
)
case
'e'
:
p
.
SetPrecision
(
prec
+
1
)
case
'g'
:
p
.
SetPrecision
(
prec
)
}
}
var
d
number
.
Decimal
d
.
Convert
(
p
.
RoundingContext
,
f
.
value
)
state
.
Write
(
p
.
Format
(
nil
,
&
d
))
}
// Digits returns information about which logical digits will be presented to
// the user. This information is relevant, for instance, to determine plural
// forms.
func
(
f
Formatter
)
Digits
(
buf
[]
byte
,
tag
language
.
Tag
,
scale
int
)
number
.
Digits
{
var
p
number
.
Formatter
f
.
initFunc
(
&
p
,
tag
)
if
scale
>=
0
{
// TODO: this only works well for decimal numbers, which is generally
// fine.
p
.
SetScale
(
scale
)
}
var
d
number
.
Decimal
d
.
Convert
(
p
.
RoundingContext
,
f
.
value
)
return
number
.
FormatDigits
(
&
d
,
p
.
RoundingContext
)
}
vendor/golang.org/x/text/number/number.go
0 → 100644
浏览文件 @
544de19c
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
number
// TODO:
// p.Printf("The gauge was at %v.", number.Spell(number.Percent(23)))
// // Prints: The gauge was at twenty-three percent.
//
// p.Printf("From here to %v!", number.Spell(math.Inf()))
// // Prints: From here to infinity!
//
import
(
"golang.org/x/text/internal/number"
)
const
(
decimalVerbs
=
"vfgd"
scientificVerbs
=
"veg"
)
// Decimal formats a number as a floating point decimal.
func
Decimal
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
decimalOptions
,
opts
,
x
)
}
var
decimalOptions
=
newOptions
(
decimalVerbs
,
(
*
number
.
Formatter
)
.
InitDecimal
)
// Scientific formats a number in scientific format.
func
Scientific
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
scientificOptions
,
opts
,
x
)
}
var
scientificOptions
=
newOptions
(
scientificVerbs
,
(
*
number
.
Formatter
)
.
InitScientific
)
// Engineering formats a number using engineering notation, which is like
// scientific notation, but with the exponent normalized to multiples of 3.
func
Engineering
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
engineeringOptions
,
opts
,
x
)
}
var
engineeringOptions
=
newOptions
(
scientificVerbs
,
(
*
number
.
Formatter
)
.
InitEngineering
)
// Percent formats a number as a percentage. A value of 1.0 means 100%.
func
Percent
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
percentOptions
,
opts
,
x
)
}
var
percentOptions
=
newOptions
(
decimalVerbs
,
(
*
number
.
Formatter
)
.
InitPercent
)
// PerMille formats a number as a per mille indication. A value of 1.0 means
// 1000‰.
func
PerMille
(
x
interface
{},
opts
...
Option
)
Formatter
{
return
newFormatter
(
perMilleOptions
,
opts
,
x
)
}
var
perMilleOptions
=
newOptions
(
decimalVerbs
,
(
*
number
.
Formatter
)
.
InitPerMille
)
// TODO:
// - Shortest: akin to verb 'g' of 'G'
//
// TODO: RBNF forms:
// - Compact: 1M 3.5T
// - CompactBinary: 1Mi 3.5Ti
// - Long: 1 million
// - Ordinal:
// - Roman: MCMIIXX
// - RomanSmall: mcmiixx
// - Text: numbers as it typically appears in running text, allowing
// language-specific choices for when to use numbers and when to use words.
// - Spell?: spelled-out number. Maybe just allow as an option?
// NOTE: both spelled-out numbers and ordinals, to render correctly, need
// detailed linguistic information from the translated string into which they
// are substituted. We will need to implement that first.
vendor/golang.org/x/text/number/option.go
0 → 100644
浏览文件 @
544de19c
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
number
import
(
"fmt"
"golang.org/x/text/internal/number"
"golang.org/x/text/language"
)
// An Option configures a Formatter.
type
Option
option
type
option
func
(
tag
language
.
Tag
,
f
*
number
.
Formatter
)
// TODO: SpellOut requires support of the ICU RBNF format.
// func SpellOut() Option
// NoSeparator causes a number to be displayed without grouping separators.
func
NoSeparator
()
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
GroupingSize
=
[
2
]
uint8
{}
}
}
// MaxIntegerDigits limits the number of integer digits, eliminating the
// most significant digits.
func
MaxIntegerDigits
(
max
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
if
max
>=
1
<<
8
{
max
=
(
1
<<
8
)
-
1
}
f
.
MaxIntegerDigits
=
uint8
(
max
)
}
}
// MinIntegerDigits specifies the minimum number of integer digits, adding
// leading zeros when needed.
func
MinIntegerDigits
(
min
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
if
min
>=
1
<<
8
{
min
=
(
1
<<
8
)
-
1
}
f
.
MinIntegerDigits
=
uint8
(
min
)
}
}
// MaxFractionDigits specifies the maximum number of fractional digits.
func
MaxFractionDigits
(
max
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
if
max
>=
1
<<
15
{
max
=
(
1
<<
15
)
-
1
}
f
.
MaxFractionDigits
=
int16
(
max
)
}
}
// MinFractionDigits specifies the minimum number of fractional digits.
func
MinFractionDigits
(
min
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
if
min
>=
1
<<
8
{
min
=
(
1
<<
8
)
-
1
}
f
.
MinFractionDigits
=
uint8
(
min
)
}
}
// Precision sets the maximum number of significant digits. A negative value
// means exact.
func
Precision
(
prec
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
SetPrecision
(
prec
)
}
}
// Scale simultaneously sets MinFractionDigits and MaxFractionDigits to the
// given value.
func
Scale
(
decimals
int
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
SetScale
(
decimals
)
}
}
// IncrementString sets the incremental value to which numbers should be
// rounded. For instance: Increment("0.05") will cause 1.44 to round to 1.45.
// IncrementString also sets scale to the scale of the increment.
func
IncrementString
(
decimal
string
)
Option
{
increment
:=
0
scale
:=
0
d
:=
decimal
p
:=
0
for
;
p
<
len
(
d
)
&&
'0'
<=
d
[
p
]
&&
d
[
p
]
<=
'9'
;
p
++
{
increment
*=
10
increment
+=
int
(
d
[
p
])
-
'0'
}
if
p
<
len
(
d
)
&&
d
[
p
]
==
'.'
{
for
p
++
;
p
<
len
(
d
)
&&
'0'
<=
d
[
p
]
&&
d
[
p
]
<=
'9'
;
p
++
{
increment
*=
10
increment
+=
int
(
d
[
p
])
-
'0'
scale
++
}
}
if
p
<
len
(
d
)
{
increment
=
0
scale
=
0
}
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
Increment
=
uint32
(
increment
)
f
.
IncrementScale
=
uint8
(
scale
)
f
.
SetScale
(
scale
)
}
}
func
noop
(
language
.
Tag
,
*
number
.
Formatter
)
{}
// PatternOverrides allows users to specify alternative patterns for specific
// languages. The Pattern will be overridden for all languages in a subgroup as
// well. The function will panic for invalid input. It is best to create this
// option at startup time.
// PatternOverrides must be the first Option passed to a formatter.
func
PatternOverrides
(
patterns
map
[
string
]
string
)
Option
{
// TODO: make it so that it does not have to be the first option.
// TODO: use -x-nochild to indicate it does not override child tags.
m
:=
map
[
language
.
Tag
]
*
number
.
Pattern
{}
for
k
,
v
:=
range
patterns
{
tag
:=
language
.
MustParse
(
k
)
p
,
err
:=
number
.
ParsePattern
(
v
)
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"number: PatternOverrides: %v"
,
err
))
}
m
[
tag
]
=
p
}
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
// TODO: Use language grouping relation instead of parent relation.
// TODO: Should parent implement the grouping relation?
for
lang
:=
t
;
;
lang
=
t
.
Parent
()
{
if
p
,
ok
:=
m
[
lang
];
ok
{
f
.
Pattern
=
*
p
break
}
if
lang
==
language
.
Und
{
break
}
}
}
}
// FormatWidth sets the total format width.
func
FormatWidth
(
n
int
)
Option
{
if
n
<=
0
{
return
noop
}
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
FormatWidth
=
uint16
(
n
)
if
f
.
PadRune
==
0
{
f
.
PadRune
=
' '
}
}
}
// Pad sets the rune to be used for filling up to the format width.
func
Pad
(
r
rune
)
Option
{
return
func
(
t
language
.
Tag
,
f
*
number
.
Formatter
)
{
f
.
PadRune
=
r
}
}
// TODO:
// - FormatPosition (using type aliasing?)
// - Multiplier: find a better way to represent and figure out what to do
// with clashes with percent/permille.
// - NumberingSystem(nu string): not accessable in number.Info now. Also, should
// this be keyed by language or generic?
// - SymbolOverrides(symbols map[string]map[number.SymbolType]string) Option
vendor/golang.org/x/text/transform/transform.go
浏览文件 @
544de19c
...
@@ -493,7 +493,7 @@ func (c *chain) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err erro
...
@@ -493,7 +493,7 @@ func (c *chain) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err erro
return
dstL
.
n
,
srcL
.
p
,
err
return
dstL
.
n
,
srcL
.
p
,
err
}
}
// Deprecated:
u
se runes.Remove instead.
// Deprecated:
U
se runes.Remove instead.
func
RemoveFunc
(
f
func
(
r
rune
)
bool
)
Transformer
{
func
RemoveFunc
(
f
func
(
r
rune
)
bool
)
Transformer
{
return
removeF
(
f
)
return
removeF
(
f
)
}
}
...
...
vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go
浏览文件 @
544de19c
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// +build go1.10
// +build go1.10
,!go1.13
package
bidi
package
bidi
...
...
vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go
0 → 100644
浏览文件 @
544de19c
此差异已折叠。
点击以展开。
vendor/golang.org/x/text/unicode/cldr/cldr.go
浏览文件 @
544de19c
...
@@ -96,7 +96,7 @@ func (cldr *CLDR) RawLDML(loc string) *LDML {
...
@@ -96,7 +96,7 @@ func (cldr *CLDR) RawLDML(loc string) *LDML {
// LDML returns the fully resolved LDML XML for loc, which must be one of
// LDML returns the fully resolved LDML XML for loc, which must be one of
// the strings returned by Locales.
// the strings returned by Locales.
//
//
// Deprecated:
u
se RawLDML and implement inheritance manually or using the
// Deprecated:
U
se RawLDML and implement inheritance manually or using the
// internal cldrtree package.
// internal cldrtree package.
// Inheritance has changed quite a bit since the onset of this package and in
// Inheritance has changed quite a bit since the onset of this package and in
// practice data often represented in a way where knowledge of how it was
// practice data often represented in a way where knowledge of how it was
...
...
vendor/golang.org/x/text/unicode/norm/tables10.0.0.go
浏览文件 @
544de19c
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// +build go1.10
// +build go1.10
,!go1.13
package
norm
package
norm
...
...
vendor/golang.org/x/text/unicode/norm/tables11.0.0.go
0 → 100644
浏览文件 @
544de19c
此差异已折叠。
点击以展开。
vendor/golang.org/x/text/unicode/rangetable/tables10.0.0.go
浏览文件 @
544de19c
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
// +build go1.10
// +build go1.10
,!go1.13
package
rangetable
package
rangetable
...
...
vendor/golang.org/x/text/unicode/rangetable/tables11.0.0.go
0 → 100644
浏览文件 @
544de19c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录