summaryrefslogtreecommitdiffstats
path: root/tpl/encoding
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/encoding
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/encoding')
-rw-r--r--tpl/encoding/encoding.go6
-rw-r--r--tpl/encoding/encoding_test.go16
-rw-r--r--tpl/encoding/init.go2
3 files changed, 12 insertions, 12 deletions
diff --git a/tpl/encoding/encoding.go b/tpl/encoding/encoding.go
index ce25151a0..272503e0c 100644
--- a/tpl/encoding/encoding.go
+++ b/tpl/encoding/encoding.go
@@ -33,7 +33,7 @@ func New() *Namespace {
type Namespace struct{}
// Base64Decode returns the base64 decoding of the given content.
-func (ns *Namespace) Base64Decode(content interface{}) (string, error) {
+func (ns *Namespace) Base64Decode(content any) (string, error) {
conv, err := cast.ToStringE(content)
if err != nil {
return "", err
@@ -44,7 +44,7 @@ func (ns *Namespace) Base64Decode(content interface{}) (string, error) {
}
// Base64Encode returns the base64 encoding of the given content.
-func (ns *Namespace) Base64Encode(content interface{}) (string, error) {
+func (ns *Namespace) Base64Encode(content any) (string, error) {
conv, err := cast.ToStringE(content)
if err != nil {
return "", err
@@ -58,7 +58,7 @@ func (ns *Namespace) Base64Encode(content interface{}) (string, error) {
// "prefix" and "indent". Each JSON element in the output will begin on a new
// line beginning with prefix followed by one or more copies of indent according
// to the indentation nesting.
-func (ns *Namespace) Jsonify(args ...interface{}) (template.HTML, error) {
+func (ns *Namespace) Jsonify(args ...any) (template.HTML, error) {
var (
b []byte
err error
diff --git a/tpl/encoding/encoding_test.go b/tpl/encoding/encoding_test.go
index 815aa2613..e7c82e3be 100644
--- a/tpl/encoding/encoding_test.go
+++ b/tpl/encoding/encoding_test.go
@@ -30,8 +30,8 @@ func TestBase64Decode(t *testing.T) {
ns := New()
for _, test := range []struct {
- v interface{}
- expect interface{}
+ v any
+ expect any
}{
{"YWJjMTIzIT8kKiYoKSctPUB+", "abc123!?$*&()'-=@~"},
// errors
@@ -57,8 +57,8 @@ func TestBase64Encode(t *testing.T) {
ns := New()
for _, test := range []struct {
- v interface{}
- expect interface{}
+ v any
+ expect any
}{
{"YWJjMTIzIT8kKiYoKSctPUB+", "WVdKak1USXpJVDhrS2lZb0tTY3RQVUIr"},
// errors
@@ -83,9 +83,9 @@ func TestJsonify(t *testing.T) {
ns := New()
for _, test := range []struct {
- opts interface{}
- v interface{}
- expect interface{}
+ opts any
+ v any
+ expect any
}{
{nil, []string{"a", "b"}, template.HTML(`["a","b"]`)},
{map[string]string{"indent": "<i>"}, []string{"a", "b"}, template.HTML("[\n<i>\"a\",\n<i>\"b\"\n]")},
@@ -97,7 +97,7 @@ func TestJsonify(t *testing.T) {
{nil, math.NaN(), false},
{tstNoStringer{}, []string{"a", "b"}, false},
} {
- args := []interface{}{}
+ args := []any{}
if test.opts != nil {
args = append(args, test.opts)
diff --git a/tpl/encoding/init.go b/tpl/encoding/init.go
index 77c9c8c49..1d42b4e37 100644
--- a/tpl/encoding/init.go
+++ b/tpl/encoding/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.Base64Decode,