summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/collections/append.go10
-rw-r--r--common/collections/append_test.go38
-rw-r--r--common/collections/collections.go2
-rw-r--r--common/collections/slice.go8
-rw-r--r--common/collections/slice_test.go32
-rw-r--r--common/herrors/errors.go2
-rw-r--r--common/hexec/exec.go8
-rw-r--r--common/hreflect/helpers.go2
-rw-r--r--common/htime/time.go2
-rw-r--r--common/hugo/vars_extended.go1
-rw-r--r--common/hugo/vars_regular.go1
-rw-r--r--common/hugo/version.go10
-rw-r--r--common/loggers/ignorableLogger.go4
-rw-r--r--common/loggers/loggers.go40
-rw-r--r--common/maps/maps.go38
-rw-r--r--common/maps/maps_test.go42
-rw-r--r--common/maps/params.go22
-rw-r--r--common/maps/params_test.go14
-rw-r--r--common/maps/scratch.go28
-rw-r--r--common/maps/scratch_test.go8
-rw-r--r--common/math/math.go2
-rw-r--r--common/math/math_test.go6
-rw-r--r--common/paths/path_test.go2
-rw-r--r--common/text/position.go2
-rw-r--r--common/text/transform.go2
-rw-r--r--common/types/convert.go14
-rw-r--r--common/types/convert_test.go2
-rw-r--r--common/types/types.go12
-rw-r--r--common/types/types_test.go2
-rw-r--r--common/urls/ref.go4
30 files changed, 181 insertions, 179 deletions
diff --git a/common/collections/append.go b/common/collections/append.go
index d6fb89241..a9c14c1aa 100644
--- a/common/collections/append.go
+++ b/common/collections/append.go
@@ -21,7 +21,7 @@ import (
// Append appends from to a slice to and returns the resulting slice.
// If length of from is one and the only element is a slice of same type as to,
// it will be appended.
-func Append(to interface{}, from ...interface{}) (interface{}, error) {
+func Append(to any, from ...any) (any, error) {
tov, toIsNil := indirect(reflect.ValueOf(to))
toIsNil = toIsNil || to == nil
@@ -73,8 +73,8 @@ func Append(to interface{}, from ...interface{}) (interface{}, error) {
return tov.Interface(), nil
}
-func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]interface{}, error) {
- var tos []interface{}
+func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]any, error) {
+ var tos []any
for _, slice := range []reflect.Value{slice1, slice2} {
for i := 0; i < slice.Len(); i++ {
@@ -85,8 +85,8 @@ func appendToInterfaceSliceFromValues(slice1, slice2 reflect.Value) ([]interface
return tos, nil
}
-func appendToInterfaceSlice(tov reflect.Value, from ...interface{}) ([]interface{}, error) {
- var tos []interface{}
+func appendToInterfaceSlice(tov reflect.Value, from ...any) ([]any, error) {
+ var tos []any
for i := 0; i < tov.Len(); i++ {
tos = append(tos, tov.Index(i).Interface())
diff --git a/common/collections/append_test.go b/common/collections/append_test.go
index 7d6117de8..6df32fee6 100644
--- a/common/collections/append_test.go
+++ b/common/collections/append_test.go
@@ -25,25 +25,25 @@ func TestAppend(t *testing.T) {
c := qt.New(t)
for _, test := range []struct {
- start interface{}
- addend []interface{}
- expected interface{}
+ start any
+ addend []any
+ expected any
}{
- {[]string{"a", "b"}, []interface{}{"c"}, []string{"a", "b", "c"}},
- {[]string{"a", "b"}, []interface{}{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}},
- {[]string{"a", "b"}, []interface{}{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}},
- {[]string{"a"}, []interface{}{"b", template.HTML("c")}, []interface{}{"a", "b", template.HTML("c")}},
- {nil, []interface{}{"a", "b"}, []string{"a", "b"}},
- {nil, []interface{}{nil}, []interface{}{nil}},
- {[]interface{}{}, []interface{}{[]string{"c", "d", "e"}}, []string{"c", "d", "e"}},
+ {[]string{"a", "b"}, []any{"c"}, []string{"a", "b", "c"}},
+ {[]string{"a", "b"}, []any{"c", "d", "e"}, []string{"a", "b", "c", "d", "e"}},
+ {[]string{"a", "b"}, []any{[]string{"c", "d", "e"}}, []string{"a", "b", "c", "d", "e"}},
+ {[]string{"a"}, []any{"b", template.HTML("c")}, []any{"a", "b", template.HTML("c")}},
+ {nil, []any{"a", "b"}, []string{"a", "b"}},
+ {nil, []any{nil}, []any{nil}},
+ {[]any{}, []any{[]string{"c", "d", "e"}}, []string{"c", "d", "e"}},
{
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
- []interface{}{&tstSlicer{"c"}},
+ []any{&tstSlicer{"c"}},
tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}, &tstSlicer{"c"}},
},
{
&tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}},
- []interface{}{&tstSlicer{"c"}},
+ []any{&tstSlicer{"c"}},
tstSlicers{
&tstSlicer{"a"},
&tstSlicer{"b"},
@@ -52,26 +52,26 @@ func TestAppend(t *testing.T) {
},
{
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}},
- []interface{}{&tstSlicerIn1{"c"}},
+ []any{&tstSlicerIn1{"c"}},
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
},
//https://github.com/gohugoio/hugo/issues/5361
{
[]string{"a", "b"},
- []interface{}{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
- []interface{}{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}},
+ []any{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
+ []any{"a", "b", &tstSlicer{"a"}, &tstSlicer{"b"}},
},
{
[]string{"a", "b"},
- []interface{}{&tstSlicer{"a"}},
- []interface{}{"a", "b", &tstSlicer{"a"}},
+ []any{&tstSlicer{"a"}},
+ []any{"a", "b", &tstSlicer{"a"}},
},
// Errors
- {"", []interface{}{[]string{"a", "b"}}, false},
+ {"", []any{[]string{"a", "b"}}, false},
// No string concatenation.
{
"ab",
- []interface{}{"c"},
+ []any{"c"},
false,
},
} {
diff --git a/common/collections/collections.go b/common/collections/collections.go
index bb47c8acc..0b46abee9 100644
--- a/common/collections/collections.go
+++ b/common/collections/collections.go
@@ -17,5 +17,5 @@ package collections
// Grouper defines a very generic way to group items by a given key.
type Grouper interface {
- Group(key interface{}, items interface{}) (interface{}, error)
+ Group(key any, items any) (any, error)
}
diff --git a/common/collections/slice.go b/common/collections/slice.go
index 07ad48eb3..51cb6ec1f 100644
--- a/common/collections/slice.go
+++ b/common/collections/slice.go
@@ -21,11 +21,11 @@ import (
// in collections.Slice template func to get types such as Pages, PageGroups etc.
// instead of the less useful []interface{}.
type Slicer interface {
- Slice(items interface{}) (interface{}, error)
+ Slice(items any) (any, error)
}
// Slice returns a slice of all passed arguments.
-func Slice(args ...interface{}) interface{} {
+func Slice(args ...any) any {
if len(args) == 0 {
return args
}
@@ -66,8 +66,8 @@ func Slice(args ...interface{}) interface{} {
}
// StringSliceToInterfaceSlice converts ss to []interface{}.
-func StringSliceToInterfaceSlice(ss []string) []interface{} {
- result := make([]interface{}, len(ss))
+func StringSliceToInterfaceSlice(ss []string) []any {
+ result := make([]any, len(ss))
for i, s := range ss {
result[i] = s
}
diff --git a/common/collections/slice_test.go b/common/collections/slice_test.go
index 93bad84da..8e6553994 100644
--- a/common/collections/slice_test.go
+++ b/common/collections/slice_test.go
@@ -46,8 +46,8 @@ type tstSlicer struct {
TheName string
}
-func (p *tstSlicerIn1) Slice(in interface{}) (interface{}, error) {
- items := in.([]interface{})
+func (p *tstSlicerIn1) Slice(in any) (any, error) {
+ items := in.([]any)
result := make(testSlicerInterfaces, len(items))
for i, v := range items {
switch vv := v.(type) {
@@ -60,8 +60,8 @@ func (p *tstSlicerIn1) Slice(in interface{}) (interface{}, error) {
return result, nil
}
-func (p *tstSlicerIn2) Slice(in interface{}) (interface{}, error) {
- items := in.([]interface{})
+func (p *tstSlicerIn2) Slice(in any) (any, error) {
+ items := in.([]any)
result := make(testSlicerInterfaces, len(items))
for i, v := range items {
switch vv := v.(type) {
@@ -82,8 +82,8 @@ func (p *tstSlicerIn2) Name() string {
return p.TheName
}
-func (p *tstSlicer) Slice(in interface{}) (interface{}, error) {
- items := in.([]interface{})
+func (p *tstSlicer) Slice(in any) (any, error) {
+ items := in.([]any)
result := make(tstSlicers, len(items))
for i, v := range items {
switch vv := v.(type) {
@@ -103,17 +103,17 @@ func TestSlice(t *testing.T) {
c := qt.New(t)
for i, test := range []struct {
- args []interface{}
- expected interface{}
+ args []any
+ expected any
}{
- {[]interface{}{"a", "b"}, []string{"a", "b"}},
- {[]interface{}{&tstSlicer{"a"}, &tstSlicer{"b"}}, tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
- {[]interface{}{&tstSlicer{"a"}, "b"}, []interface{}{&tstSlicer{"a"}, "b"}},
- {[]interface{}{}, []interface{}{}},
- {[]interface{}{nil}, []interface{}{nil}},
- {[]interface{}{5, "b"}, []interface{}{5, "b"}},
- {[]interface{}{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}, testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}},
- {[]interface{}{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}, []interface{}{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}},
+ {[]any{"a", "b"}, []string{"a", "b"}},
+ {[]any{&tstSlicer{"a"}, &tstSlicer{"b"}}, tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
+ {[]any{&tstSlicer{"a"}, "b"}, []any{&tstSlicer{"a"}, "b"}},
+ {[]any{}, []any{}},
+ {[]any{nil}, []any{nil}},
+ {[]any{5, "b"}, []any{5, "b"}},
+ {[]any{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}, testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn2{"b"}}},
+ {[]any{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}, []any{&tstSlicerIn1{"a"}, &tstSlicer{"b"}}},
} {
errMsg := qt.Commentf("[%d] %v", i, test.args)
diff --git a/common/herrors/errors.go b/common/herrors/errors.go
index 00aed1eb6..27cfd2693 100644
--- a/common/herrors/errors.go
+++ b/common/herrors/errors.go
@@ -65,7 +65,7 @@ type ErrorSender interface {
// Recover is a helper function that can be used to capture panics.
// Put this at the top of a method/function that crashes in a template:
// defer herrors.Recover()
-func Recover(args ...interface{}) {
+func Recover(args ...any) {
if r := recover(); r != nil {
fmt.Println("ERR:", r)
args = append(args, "stacktrace from panic: \n"+string(debug.Stack()), "\n")
diff --git a/common/hexec/exec.go b/common/hexec/exec.go
index a8bdd1bb7..7a9fdd938 100644
--- a/common/hexec/exec.go
+++ b/common/hexec/exec.go
@@ -128,7 +128,7 @@ type Exec struct {
// New will fail if name is not allowed according to the configured security policy.
// Else a configured Runner will be returned ready to be Run.
-func (e *Exec) New(name string, arg ...interface{}) (Runner, error) {
+func (e *Exec) New(name string, arg ...any) (Runner, error) {
if err := e.sc.CheckAllowedExec(name); err != nil {
return nil, err
}
@@ -146,8 +146,8 @@ func (e *Exec) New(name string, arg ...interface{}) (Runner, error) {
}
// Npx is a convenience method to create a Runner running npx --no-install <name> <args.
-func (e *Exec) Npx(name string, arg ...interface{}) (Runner, error) {
- arg = append(arg[:0], append([]interface{}{"--no-install", name}, arg[0:]...)...)
+func (e *Exec) Npx(name string, arg ...any) (Runner, error) {
+ arg = append(arg[:0], append([]any{"--no-install", name}, arg[0:]...)...)
return e.New("npx", arg...)
}
@@ -205,7 +205,7 @@ type commandeer struct {
env []string
}
-func (c *commandeer) command(arg ...interface{}) (*cmdWrapper, error) {
+func (c *commandeer) command(arg ...any) (*cmdWrapper, error) {
if c == nil {
return nil, nil
}
diff --git a/common/hreflect/helpers.go b/common/hreflect/helpers.go
index 7087a9677..7f3ef7ac2 100644
--- a/common/hreflect/helpers.go
+++ b/common/hreflect/helpers.go
@@ -62,7 +62,7 @@ func IsFloat(kind reflect.Kind) bool {
// IsTruthful returns whether in represents a truthful value.
// See IsTruthfulValue
-func IsTruthful(in interface{}) bool {
+func IsTruthful(in any) bool {
switch v := in.(type) {
case reflect.Value:
return IsTruthfulValue(v)
diff --git a/common/htime/time.go b/common/htime/time.go
index 9ab249d38..552608b6f 100644
--- a/common/htime/time.go
+++ b/common/htime/time.go
@@ -134,7 +134,7 @@ func (f TimeFormatter) Format(t time.Time, layout string) string {
return s
}
-func ToTimeInDefaultLocationE(i interface{}, location *time.Location) (tim time.Time, err error) {
+func ToTimeInDefaultLocationE(i any, location *time.Location) (tim time.Time, err error) {
switch vv := i.(type) {
case toml.LocalDate:
return vv.AsTime(location), nil
diff --git a/common/hugo/vars_extended.go b/common/hugo/vars_extended.go
index bb96bade6..edbaff243 100644
--- a/common/hugo/vars_extended.go
+++ b/common/hugo/vars_extended.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build extended
// +build extended
package hugo
diff --git a/common/hugo/vars_regular.go b/common/hugo/vars_regular.go
index fae18df14..223df4b6c 100644
--- a/common/hugo/vars_regular.go
+++ b/common/hugo/vars_regular.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !extended
// +build !extended
package hugo
diff --git a/common/hugo/version.go b/common/hugo/version.go
index b085744c9..0c78174c5 100644
--- a/common/hugo/version.go
+++ b/common/hugo/version.go
@@ -58,13 +58,13 @@ func (h VersionString) String() string {
}
// Compare implements the compare.Comparer interface.
-func (h VersionString) Compare(other interface{}) int {
+func (h VersionString) Compare(other any) int {
v := MustParseVersion(h.String())
return compareVersionsWithSuffix(v.Number, v.PatchLevel, v.Suffix, other)
}
// Eq implements the compare.Eqer interface.
-func (h VersionString) Eq(other interface{}) bool {
+func (h VersionString) Eq(other any) bool {
s, err := cast.ToStringE(other)
if err != nil {
return false
@@ -171,15 +171,15 @@ func version(version float32, patchVersion int, suffix string) string {
// running Hugo version.
// It returns -1 if the given version is less than, 0 if equal and 1 if greater than
// the running version.
-func CompareVersion(version interface{}) int {
+func CompareVersion(version any) int {
return compareVersionsWithSuffix(CurrentVersion.Number, CurrentVersion.PatchLevel, CurrentVersion.Suffix, version)
}
-func compareVersions(inVersion float32, inPatchVersion int, in interface{}) int {
+func compareVersions(inVersion float32, inPatchVersion int, in any) int {
return compareVersionsWithSuffix(inVersion, inPatchVersion, "", in)
}
-func compareVersionsWithSuffix(inVersion float32, inPatchVersion int, suffix string, in interface{}) int {
+func compareVersionsWithSuffix(inVersion float32, inPatchVersion int, suffix string, in any) int {
var c int
switch d := in.(type) {
case float64:
diff --git a/common/loggers/ignorableLogger.go b/common/loggers/ignorableLogger.go
index 0a130900d..5040d1036 100644
--- a/common/loggers/ignorableLogger.go
+++ b/common/loggers/ignorableLogger.go
@@ -21,7 +21,7 @@ import (
// IgnorableLogger is a logger that ignores certain log statements.
type IgnorableLogger interface {
Logger
- Errorsf(statementID, format string, v ...interface{})
+ Errorsf(statementID, format string, v ...any)
Apply(logger Logger) IgnorableLogger
}
@@ -43,7 +43,7 @@ func NewIgnorableLogger(logger Logger, statements ...string) IgnorableLogger {
}
// Errorsf logs statementID as an ERROR if not configured as ignoreable.
-func (l ignorableLogger) Errorsf(statementID, format string, v ...interface{}) {
+func (l ignorableLogger) Errorsf(statementID, format string, v ...any) {
if l.statements[statementID] {
// Ignore.
return
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go
index 72330e525..14c76ae45 100644
--- a/common/loggers/loggers.go
+++ b/common/loggers/loggers.go
@@ -58,21 +58,21 @@ func (w prefixWriter) Write(p []byte) (n int, err error) {
}
type Logger interface {
- Printf(format string, v ...interface{})
- Println(v ...interface{})
+ Printf(format string, v ...any)
+ Println(v ...any)
PrintTimerIfDelayed(start time.Time, name string)
Debug() *log.Logger
- Debugf(format string, v ...interface{})
- Debugln(v ...interface{})
+ Debugf(format string, v ...any)
+ Debugln(v ...any)
Info() *log.Logger
- Infof(format string, v ...interface{})
- Infoln(v ...interface{})
+ Infof(format string, v ...any)
+ Infoln(v ...any)
Warn() *log.Logger
- Warnf(format string, v ...interface{})
- Warnln(v ...interface{})
+ Warnf(format string, v ...any)
+ Warnln(v ...any)
Error() *log.Logger
- Errorf(format string, v ...interface{})
- Errorln(v ...interface{})
+ Errorf(format string, v ...any)
+ Errorln(v ...any)
Errors() string
Out() io.Writer
@@ -101,11 +101,11 @@ type logger struct {
errors *bytes.Buffer
}
-func (l *logger) Printf(format string, v ...interface{}) {
+func (l *logger) Printf(format string, v ...any) {
l.FEEDBACK.Printf(format, v...)
}
-func (l *logger) Println(v ...interface{}) {
+func (l *logger) Println(v ...any) {
l.FEEDBACK.Println(v...)
}
@@ -113,19 +113,19 @@ func (l *logger) Debug() *log.Logger {
return l.DEBUG
}
-func (l *logger) Debugf(format string, v ...interface{}) {
+func (l *logger) Debugf(format string, v ...any) {
l.DEBUG.Printf(format, v...)
}
-func (l *logger) Debugln(v ...interface{}) {
+func (l *logger) Debugln(v ...any) {
l.DEBUG.Println(v...)
}
-func (l *logger) Infof(format string, v ...interface{}) {
+func (l *logger) Infof(format string, v ...any) {
l.INFO.Printf(format, v...)
}
-func (l *logger) Infoln(v ...interface{}) {
+func (l *logger) Infoln(v ...any) {
l.INFO.Println(v...)
}
@@ -135,14 +135,14 @@ func (l *logger) Info() *log.Logger {
const panicOnWarningMessage = "Warning trapped. Remove the --panicOnWarning flag to continue."
-func (l *logger) Warnf(format string, v ...interface{}) {
+func (l *logger) Warnf(format string, v ...any) {
l.WARN.Printf(format, v...)
if PanicOnWarning {
panic(panicOnWarningMessage)
}
}
-func (l *logger) Warnln(v ...interface{}) {
+func (l *logger) Warnln(v ...any) {
l.WARN.Println(v...)
if PanicOnWarning {
panic(panicOnWarningMessage)
@@ -153,11 +153,11 @@ func (l *logger) Warn() *log.Logger {
return l.WARN
}
-func (l *logger) Errorf(format string, v ...interface{}) {
+func (l *logger) Errorf(format string, v ...any) {
l.ERROR.Printf(format, v...)
}
-func (l *logger) Errorln(v ...interface{}) {
+func (l *logger) Errorln(v ...any) {
l.ERROR.Println(v...)
}
diff --git a/common/maps/maps.go b/common/maps/maps.go
index b5e9ba2f5..5552da55d 100644
--- a/common/maps/maps.go
+++ b/common/maps/maps.go
@@ -24,12 +24,12 @@ import (
)
// ToStringMapE converts in to map[string]interface{}.
-func ToStringMapE(in interface{}) (map[string]interface{}, error) {
+func ToStringMapE(in any) (map[string]any, error) {
switch vv := in.(type) {
case Params:
return vv, nil
case map[string]string:
- var m = map[string]interface{}{}
+ var m = map[string]any{}
for k, v := range vv {
m[k] = v
}
@@ -43,7 +43,7 @@ func ToStringMapE(in interface{}) (map[string]interface{}, error) {
// ToParamsAndPrepare converts in to Params and prepares it for use.
// If in is nil, an empty map is returned.
// See PrepareParams.
-func ToParamsAndPrepare(in interface{}) (Params, bool) {
+func ToParamsAndPrepare(in any) (Params, bool) {
if types.IsNil(in) {
return Params{}, true
}
@@ -56,7 +56,7 @@ func ToParamsAndPrepare(in interface{}) (Params, bool) {
}
// MustToParamsAndPrepare calls ToParamsAndPrepare and panics if it fails.
-func MustToParamsAndPrepare(in interface{}) Params {
+func MustToParamsAndPrepare(in any) Params {
if p, ok := ToParamsAndPrepare(in); ok {
return p
} else {
@@ -65,13 +65,13 @@ func MustToParamsAndPrepare(in interface{}) Params {
}
// ToStringMap converts in to map[string]interface{}.
-func ToStringMap(in interface{}) map[string]interface{} {
+func ToStringMap(in any) map[string]any {
m, _ := ToStringMapE(in)
return m
}
// ToStringMapStringE converts in to map[string]string.
-func ToStringMapStringE(in interface{}) (map[string]string, error) {
+func ToStringMapStringE(in any) (map[string]string, error) {
m, err := ToStringMapE(in)
if err != nil {
return nil, err
@@ -80,26 +80,26 @@ func ToStringMapStringE(in interface{}) (map[string]string, error) {
}
// ToStringMapString converts in to map[string]string.
-func ToStringMapString(in interface{}) map[string]string {
+func ToStringMapString(in any) map[string]string {
m, _ := ToStringMapStringE(in)
return m
}
// ToStringMapBool converts in to bool.
-func ToStringMapBool(in interface{}) map[string]bool {
+func ToStringMapBool(in any) map[string]bool {
m, _ := ToStringMapE(in)
return cast.ToStringMapBool(m)
}
// ToSliceStringMap converts in to []map[string]interface{}.
-func ToSliceStringMap(in interface{}) ([]map[string]interface{}, error) {
+func ToSliceStringMap(in any) ([]map[string]any, error) {
switch v := in.(type) {
- case []map[string]interface{}:
+ case []map[string]any:
return v, nil
- case []interface{}:
- var s []map[string]interface{}
+ case []any:
+ var s []map[string]any
for _, entry := range v {
- if vv, ok := entry.(map[string]interface{}); ok {
+ if vv, ok := entry.(map[string]any); ok {
s = append(s, vv)
}
}
@@ -146,7 +146,7 @@ func (r KeyRenamer) getNewKey(keyPath string) string {
// Rename renames the keys in the given map according
// to the patterns in the current KeyRenamer.
-func (r KeyRenamer) Rename(m map[string]interface{}) {
+func (r KeyRenamer) Rename(m map[string]any) {
r.renamePath("", m)
}
@@ -158,15 +158,15 @@ func (KeyRenamer) keyPath(k1, k2 string) string {
return k1 + "/" + k2
}
-func (r KeyRenamer) renamePath(parentKeyPath string, m map[string]interface{}) {
+func (r KeyRenamer) renamePath(parentKeyPath string, m map[string]any) {
for key, val := range m {
keyPath := r.keyPath(parentKeyPath, key)
switch val.(type) {
- case map[interface{}]interface{}:
+ case map[any]any:
val = cast.ToStringMap(val)
- r.renamePath(keyPath, val.(map[string]interface{}))
- case map[string]interface{}:
- r.renamePath(keyPath, val.(map[string]interface{}))
+ r.renamePath(keyPath, val.(map[string]any))
+ case map[string]any:
+ r.renamePath(keyPath, val.(map[string]any))
}
newKey := r.getNewKey(keyPath)
diff --git a/common/maps/maps_test.go b/common/maps/maps_test.go
index f0c32b9fe..53120dce7 100644
--- a/common/maps/maps_test.go
+++ b/common/maps/maps_test.go
@@ -27,7 +27,7 @@ func TestPrepareParams(t *testing.T) {
expected Params
}{
{
- map[string]interface{}{
+ map[string]any{
"abC": 32,
},
Params{
@@ -35,16 +35,16 @@ func TestPrepareParams(t *testing.T) {
},
},
{
- map[string]interface{}{
+ map[string]any{
"abC": 32,
- "deF": map[interface{}]interface{}{
+ "deF": map[any]any{
23: "A value",
- 24: map[string]interface{}{
+ 24: map[string]any{
"AbCDe": "A value",
"eFgHi": "Another value",
},
},
- "gHi": map[string]interface{}{
+ "gHi": map[string]any{
"J": 25,
},
"jKl": map[string]string{
@@ -85,23 +85,23 @@ func TestToSliceStringMap(