summaryrefslogtreecommitdiffstats
path: root/tpl/cast
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
commitb80853de90b10171155b8f3fde47d64ec7bfa0dd (patch)
tree435d3dbf7a495a0c6ce64c9769e037179aa0d27b /tpl/cast
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/cast')
-rw-r--r--tpl/cast/cast.go8
-rw-r--r--tpl/cast/cast_test.go12
-rw-r--r--tpl/cast/docshelper.go2
-rw-r--r--tpl/cast/init.go2
4 files changed, 12 insertions, 12 deletions
diff --git a/tpl/cast/cast.go b/tpl/cast/cast.go
index c864b5e32..000e315f1 100644
--- a/tpl/cast/cast.go
+++ b/tpl/cast/cast.go
@@ -30,23 +30,23 @@ type Namespace struct {
}
// ToInt converts the given value to an int.
-func (ns *Namespace) ToInt(v interface{}) (int, error) {
+func (ns *Namespace) ToInt(v any) (int, error) {
v = convertTemplateToString(v)
return _cast.ToIntE(v)
}
// ToString converts the given value to a string.
-func (ns *Namespace) ToString(v interface{}) (string, error) {
+func (ns *Namespace) ToString(v any) (string, error) {
return _cast.ToStringE(v)
}
// ToFloat converts the given value to a float.
-func (ns *Namespace) ToFloat(v interface{}) (float64, error) {
+func (ns *Namespace) ToFloat(v any) (float64, error) {
v = convertTemplateToString(v)
return _cast.ToFloat64E(v)
}
-func convertTemplateToString(v interface{}) interface{} {
+func convertTemplateToString(v any) any {
switch vv := v.(type) {
case template.HTML:
v = string(vv)
diff --git a/tpl/cast/cast_test.go b/tpl/cast/cast_test.go
index c6219728b..5b4a36c3a 100644
--- a/tpl/cast/cast_test.go
+++ b/tpl/cast/cast_test.go
@@ -27,8 +27,8 @@ func TestToInt(t *testing.T) {
ns := New()
for i, test := range []struct {
- v interface{}
- expect interface{}
+ v any
+ expect any
}{
{"1", 1},
{template.HTML("2"), 2},
@@ -59,8 +59,8 @@ func TestToString(t *testing.T) {
ns := New()
for i, test := range []struct {
- v interface{}
- expect interface{}
+ v any
+ expect any
}{
{1, "1"},
{template.HTML("2"), "2"},
@@ -87,8 +87,8 @@ func TestToFloat(t *testing.T) {
ns := New()
for i, test := range []struct {
- v interface{}
- expect interface{}
+ v any
+ expect any
}{
{"1", 1.0},
{template.HTML("2"), 2.0},
diff --git a/tpl/cast/docshelper.go b/tpl/cast/docshelper.go
index 9a5d55b3d..1c7b9c888 100644
--- a/tpl/cast/docshelper.go
+++ b/tpl/cast/docshelper.go
@@ -43,7 +43,7 @@ func init() {
}
- return docshelper.DocProvider{"tpl": map[string]interface{}{"funcs": namespaces}}
+ return docshelper.DocProvider{"tpl": map[string]any{"funcs": namespaces}}
}
docshelper.AddDocProviderFunc(docsProvider)
diff --git a/tpl/cast/init.go b/tpl/cast/init.go
index 079be4719..f1badf993 100644
--- a/tpl/cast/init.go
+++ b/tpl/cast/init.go
@@ -26,7 +26,7 @@ func init() {
ns := &internal.TemplateFuncsNamespace{
Name: name,
- Context: func(args ...interface{}) (interface{}, error) { return ctx, nil },
+ Context: func(args ...any) (any, error) { return ctx, nil },
}
ns.AddMethodMapping(ctx.ToInt,