pkg: update documentation and run gofmt
Just a run of go generate ./... and go fmt ./...
Change-Id: I5200aca2ec1d7421fb4cff883597b6564fbde7a5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3786
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/doc/tutorial/kubernetes/tut_test.go b/doc/tutorial/kubernetes/tut_test.go
index 263295c..9e21d89 100644
--- a/doc/tutorial/kubernetes/tut_test.go
+++ b/doc/tutorial/kubernetes/tut_test.go
@@ -28,8 +28,8 @@
"strings"
"testing"
- "cuelang.org/go/internal/cuetest"
"cuelang.org/go/internal/copy"
+ "cuelang.org/go/internal/cuetest"
"github.com/kylelemons/godebug/diff"
)
diff --git a/pkg/strconv/strconv.go b/pkg/strconv/strconv.go
index 06213d5..e091af0 100644
--- a/pkg/strconv/strconv.go
+++ b/pkg/strconv/strconv.go
@@ -39,9 +39,13 @@
// When bitSize=32, the result still has type float64, but it will be
// convertible to float32 without changing its value.
//
-// If s is well-formed and near a valid floating point number,
-// ParseFloat returns the nearest floating point number rounded
+// ParseFloat accepts decimal and hexadecimal floating-point number syntax.
+// If s is well-formed and near a valid floating-point number,
+// ParseFloat returns the nearest floating-point number rounded
// using IEEE754 unbiased rounding.
+// (Parsing a hexadecimal floating-point value only rounds when
+// there are more bits in the hexadecimal representation than
+// will fit in the mantissa.)
//
// The errors that ParseFloat returns have concrete type *NumError
// and include err.Num = s.
@@ -51,6 +55,9 @@
// If s is syntactically well-formed but is more than 1/2 ULP
// away from the largest floating point number of the given size,
// ParseFloat returns f = ±Inf, err.Err = ErrRange.
+//
+// ParseFloat recognizes the strings "NaN", "+Inf", and "-Inf" as their
+// respective special floating point values. It ignores case when matching.
func ParseFloat(s string, bitSize int) (float64, error) {
return strconv.ParseFloat(s, bitSize)
}
@@ -67,13 +74,15 @@
// bit size (0 to 64) and returns the corresponding value i.
//
// If base == 0, the base is implied by the string's prefix:
-// base 16 for "0x", base 8 for "0", and base 10 otherwise.
-// For bases 1, below 0 or above 36 an error is returned.
+// base 2 for "0b", base 8 for "0" or "0o", base 16 for "0x",
+// and base 10 otherwise. Also, for base == 0 only, underscore
+// characters are permitted per the Go integer literal syntax.
+// If base is below 0, is 1, or is above 36, an error is returned.
//
// The bitSize argument specifies the integer type
// that the result must fit into. Bit sizes 0, 8, 16, 32, and 64
// correspond to int, int8, int16, int32, and int64.
-// For a bitSize below 0 or above 64 an error is returned.
+// If bitSize is below 0 or above 64, an error is returned.
//
// The errors that ParseInt returns have concrete type *NumError
// and include err.Num = s. If s is empty or contains invalid
@@ -101,12 +110,14 @@
// 'e' (-d.dddde±dd, a decimal exponent),
// 'E' (-d.ddddE±dd, a decimal exponent),
// 'f' (-ddd.dddd, no exponent),
-// 'g' ('e' for large exponents, 'f' otherwise), or
-// 'G' ('E' for large exponents, 'f' otherwise).
+// 'g' ('e' for large exponents, 'f' otherwise),
+// 'G' ('E' for large exponents, 'f' otherwise),
+// 'x' (-0xd.ddddp±ddd, a hexadecimal fraction and binary exponent), or
+// 'X' (-0Xd.ddddP±ddd, a hexadecimal fraction and binary exponent).
//
// The precision prec controls the number of digits (excluding the exponent)
-// printed by the 'e', 'E', 'f', 'g', and 'G' formats.
-// For 'e', 'E', and 'f' it is the number of digits after the decimal point.
+// printed by the 'e', 'E', 'f', 'g', 'G', 'x', and 'X' formats.
+// For 'e', 'E', 'f', 'x', and 'X', it is the number of digits after the decimal point.
// For 'g' and 'G' it is the maximum number of significant digits (trailing
// zeros are removed).
// The special precision -1 uses the smallest number of digits
diff --git a/pkg/strings/strings.go b/pkg/strings/strings.go
index 888cf1b..73df2a1 100644
--- a/pkg/strings/strings.go
+++ b/pkg/strings/strings.go
@@ -153,16 +153,22 @@
return strings.Repeat(s, count)
}
-// ToUpper returns a copy of the string s with all Unicode letters mapped to their upper case.
+// ToUpper returns s with all Unicode letters mapped to their upper case.
func ToUpper(s string) string {
return strings.ToUpper(s)
}
-// ToLower returns a copy of the string s with all Unicode letters mapped to their lower case.
+// ToLower returns s with all Unicode letters mapped to their lower case.
func ToLower(s string) string {
return strings.ToLower(s)
}
+// ToValidUTF8 returns a copy of the string s with each run of invalid UTF-8 byte sequences
+// replaced by the replacement string, which may be empty.
+func ToValidUTF8(s, replacement string) string {
+ return strings.ToValidUTF8(s, replacement)
+}
+
// Trim returns a slice of the string s with all leading and
// trailing Unicode code points contained in cutset removed.
func Trim(s string, cutset string) string {
diff --git a/pkg/tool/exec/doc.go b/pkg/tool/exec/doc.go
index 90a0d09..43087a3 100644
--- a/pkg/tool/exec/doc.go
+++ b/pkg/tool/exec/doc.go
@@ -26,8 +26,9 @@
// // stderr is like stdout, but for errors.
// stderr: *null | string | bytes
//
-// // stdin specifies the input for the process.
-// stdin?: string | bytes
+// // stdin specifies the input for the process. If null, stdin of the current
+// // process is used.
+// stdin: *null | string | bytes
//
// // success is set to true when the process terminates with with a zero exit
// // code or false otherwise. The user can explicitly specify the value