all: gofmt -w -r 'interface{} -> any' .

Updates #9687
This commit is contained in:
Bjørn Erik Pedersen
2022-03-17 22:03:27 +01:00
parent 423594e03a
commit b80853de90
342 changed files with 2118 additions and 2102 deletions

View File

@@ -45,7 +45,7 @@ type Namespace struct {
}
// CountRunes returns the number of runes in s, excluding whitespace.
func (ns *Namespace) CountRunes(s interface{}) (int, error) {
func (ns *Namespace) CountRunes(s any) (int, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return 0, _errors.Wrap(err, "Failed to convert content to string")
@@ -62,7 +62,7 @@ func (ns *Namespace) CountRunes(s interface{}) (int, error) {
}
// RuneCount returns the number of runes in s.
func (ns *Namespace) RuneCount(s interface{}) (int, error) {
func (ns *Namespace) RuneCount(s any) (int, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return 0, _errors.Wrap(err, "Failed to convert content to string")
@@ -71,7 +71,7 @@ func (ns *Namespace) RuneCount(s interface{}) (int, error) {
}
// CountWords returns the approximate word count in s.
func (ns *Namespace) CountWords(s interface{}) (int, error) {
func (ns *Namespace) CountWords(s any) (int, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return 0, _errors.Wrap(err, "Failed to convert content to string")
@@ -101,7 +101,7 @@ func (ns *Namespace) CountWords(s interface{}) (int, error) {
// Count counts the number of non-overlapping instances of substr in s.
// If substr is an empty string, Count returns 1 + the number of Unicode code points in s.
func (ns *Namespace) Count(substr, s interface{}) (int, error) {
func (ns *Namespace) Count(substr, s any) (int, error) {
substrs, err := cast.ToStringE(substr)
if err != nil {
return 0, _errors.Wrap(err, "Failed to convert substr to string")
@@ -114,7 +114,7 @@ func (ns *Namespace) Count(substr, s interface{}) (int, error) {
}
// Chomp returns a copy of s with all trailing newline characters removed.
func (ns *Namespace) Chomp(s interface{}) (interface{}, error) {
func (ns *Namespace) Chomp(s any) (any, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -130,7 +130,7 @@ func (ns *Namespace) Chomp(s interface{}) (interface{}, error) {
}
// Contains reports whether substr is in s.
func (ns *Namespace) Contains(s, substr interface{}) (bool, error) {
func (ns *Namespace) Contains(s, substr any) (bool, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return false, err
@@ -145,7 +145,7 @@ func (ns *Namespace) Contains(s, substr interface{}) (bool, error) {
}
// ContainsAny reports whether any Unicode code points in chars are within s.
func (ns *Namespace) ContainsAny(s, chars interface{}) (bool, error) {
func (ns *Namespace) ContainsAny(s, chars any) (bool, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return false, err
@@ -160,7 +160,7 @@ func (ns *Namespace) ContainsAny(s, chars interface{}) (bool, error) {
}
// HasPrefix tests whether the input s begins with prefix.
func (ns *Namespace) HasPrefix(s, prefix interface{}) (bool, error) {
func (ns *Namespace) HasPrefix(s, prefix any) (bool, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return false, err
@@ -175,7 +175,7 @@ func (ns *Namespace) HasPrefix(s, prefix interface{}) (bool, error) {
}
// HasSuffix tests whether the input s begins with suffix.
func (ns *Namespace) HasSuffix(s, suffix interface{}) (bool, error) {
func (ns *Namespace) HasSuffix(s, suffix any) (bool, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return false, err
@@ -192,7 +192,7 @@ func (ns *Namespace) HasSuffix(s, suffix interface{}) (bool, error) {
// Replace returns a copy of the string s with all occurrences of old replaced
// with new. The number of replacements can be limited with an optional fourth
// parameter.
func (ns *Namespace) Replace(s, old, new interface{}, limit ...interface{}) (string, error) {
func (ns *Namespace) Replace(s, old, new any, limit ...any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -223,7 +223,7 @@ func (ns *Namespace) Replace(s, old, new interface{}, limit ...interface{}) (str
// SliceString slices a string by specifying a half-open range with
// two indices, start and end. 1 and 4 creates a slice including elements 1 through 3.
// The end index can be omitted, it defaults to the string's length.
func (ns *Namespace) SliceString(a interface{}, startEnd ...interface{}) (string, error) {
func (ns *Namespace) SliceString(a any, startEnd ...any) (string, error) {
aStr, err := cast.ToStringE(a)
if err != nil {
return "", err
@@ -267,7 +267,7 @@ func (ns *Namespace) SliceString(a interface{}, startEnd ...interface{}) (string
}
// Split slices an input string into all substrings separated by delimiter.
func (ns *Namespace) Split(a interface{}, delimiter string) ([]string, error) {
func (ns *Namespace) Split(a any, delimiter string) ([]string, error) {
aStr, err := cast.ToStringE(a)
if err != nil {
return []string{}, err
@@ -288,7 +288,7 @@ func (ns *Namespace) Split(a interface{}, delimiter string) ([]string, error) {
// In addition, borrowing from the extended behavior described at http://php.net/substr,
// if length is given and is negative, then that many characters will be omitted from
// the end of string.
func (ns *Namespace) Substr(a interface{}, nums ...interface{}) (string, error) {
func (ns *Namespace) Substr(a any, nums ...any) (string, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", err
@@ -363,7 +363,7 @@ func (ns *Namespace) Substr(a interface{}, nums ...interface{}) (string, error)
// Title returns a copy of the input s with all Unicode letters that begin words
// mapped to their title case.
func (ns *Namespace) Title(s interface{}) (string, error) {
func (ns *Namespace) Title(s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -373,7 +373,7 @@ func (ns *Namespace) Title(s interface{}) (string, error) {
}
// FirstUpper returns a string with the first character as upper case.
func (ns *Namespace) FirstUpper(s interface{}) (string, error) {
func (ns *Namespace) FirstUpper(s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -384,7 +384,7 @@ func (ns *Namespace) FirstUpper(s interface{}) (string, error) {
// ToLower returns a copy of the input s with all Unicode letters mapped to their
// lower case.
func (ns *Namespace) ToLower(s interface{}) (string, error) {
func (ns *Namespace) ToLower(s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -395,7 +395,7 @@ func (ns *Namespace) ToLower(s interface{}) (string, error) {
// ToUpper returns a copy of the input s with all Unicode letters mapped to their
// upper case.
func (ns *Namespace) ToUpper(s interface{}) (string, error) {
func (ns *Namespace) ToUpper(s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -406,7 +406,7 @@ func (ns *Namespace) ToUpper(s interface{}) (string, error) {
// Trim returns a string with all leading and trailing characters defined
// contained in cutset removed.
func (ns *Namespace) Trim(s, cutset interface{}) (string, error) {
func (ns *Namespace) Trim(s, cutset any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -422,7 +422,7 @@ func (ns *Namespace) Trim(s, cutset interface{}) (string, error) {
// TrimLeft returns a slice of the string s with all leading characters
// contained in cutset removed.
func (ns *Namespace) TrimLeft(cutset, s interface{}) (string, error) {
func (ns *Namespace) TrimLeft(cutset, s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -438,7 +438,7 @@ func (ns *Namespace) TrimLeft(cutset, s interface{}) (string, error) {
// TrimPrefix returns s without the provided leading prefix string. If s doesn't
// start with prefix, s is returned unchanged.
func (ns *Namespace) TrimPrefix(prefix, s interface{}) (string, error) {
func (ns *Namespace) TrimPrefix(prefix, s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -454,7 +454,7 @@ func (ns *Namespace) TrimPrefix(prefix, s interface{}) (string, error) {
// TrimRight returns a slice of the string s with all trailing characters
// contained in cutset removed.
func (ns *Namespace) TrimRight(cutset, s interface{}) (string, error) {
func (ns *Namespace) TrimRight(cutset, s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -470,7 +470,7 @@ func (ns *Namespace) TrimRight(cutset, s interface{}) (string, error) {
// TrimSuffix returns s without the provided trailing suffix string. If s
// doesn't end with suffix, s is returned unchanged.
func (ns *Namespace) TrimSuffix(suffix, s interface{}) (string, error) {
func (ns *Namespace) TrimSuffix(suffix, s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err
@@ -485,7 +485,7 @@ func (ns *Namespace) TrimSuffix(suffix, s interface{}) (string, error) {
}
// Repeat returns a new string consisting of count copies of the string s.
func (ns *Namespace) Repeat(n, s interface{}) (string, error) {
func (ns *Namespace) Repeat(n, s any) (string, error) {
ss, err := cast.ToStringE(s)
if err != nil {
return "", err