diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-17 22:03:27 +0100 |
commit | b80853de90b10171155b8f3fde47d64ec7bfa0dd (patch) | |
tree | 435d3dbf7a495a0c6ce64c9769e037179aa0d27b /tpl/crypto | |
parent | 423594e03a906ef4150f433666ff588b022c3c92 (diff) |
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/crypto')
-rw-r--r-- | tpl/crypto/crypto.go | 8 | ||||
-rw-r--r-- | tpl/crypto/crypto_test.go | 20 | ||||
-rw-r--r-- | tpl/crypto/init.go | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/tpl/crypto/crypto.go b/tpl/crypto/crypto.go index 3a825bf15..785b13502 100644 --- a/tpl/crypto/crypto.go +++ b/tpl/crypto/crypto.go @@ -36,7 +36,7 @@ func New() *Namespace { type Namespace struct{} // MD5 hashes the given input and returns its MD5 checksum. -func (ns *Namespace) MD5(in interface{}) (string, error) { +func (ns *Namespace) MD5(in any) (string, error) { conv, err := cast.ToStringE(in) if err != nil { return "", err @@ -47,7 +47,7 @@ func (ns *Namespace) MD5(in interface{}) (string, error) { } // SHA1 hashes the given input and returns its SHA1 checksum. -func (ns *Namespace) SHA1(in interface{}) (string, error) { +func (ns *Namespace) SHA1(in any) (string, error) { conv, err := cast.ToStringE(in) if err != nil { return "", err @@ -58,7 +58,7 @@ func (ns *Namespace) SHA1(in interface{}) (string, error) { } // SHA256 hashes the given input and returns its SHA256 checksum. -func (ns *Namespace) SHA256(in interface{}) (string, error) { +func (ns *Namespace) SHA256(in any) (string, error) { conv, err := cast.ToStringE(in) if err != nil { return "", err @@ -69,7 +69,7 @@ func (ns *Namespace) SHA256(in interface{}) (string, error) { } // HMAC returns a cryptographic hash that uses a key to sign a message. -func (ns *Namespace) HMAC(h interface{}, k interface{}, m interface{}) (string, error) { +func (ns *Namespace) HMAC(h any, k any, m any) (string, error) { ha, err := cast.ToStringE(h) if err != nil { return "", err diff --git a/tpl/crypto/crypto_test.go b/tpl/crypto/crypto_test.go index fe82f2afd..78e387318 100644 --- a/tpl/crypto/crypto_test.go +++ b/tpl/crypto/crypto_test.go @@ -26,8 +26,8 @@ func TestMD5(t *testing.T) { ns := New() for i, test := range []struct { - in interface{} - expect interface{} + in any + expect any }{ {"Hello world, gophers!", "b3029f756f98f79e7f1b7f1d1f0dd53b"}, {"Lorem ipsum dolor", "06ce65ac476fc656bea3fca5d02cfd81"}, @@ -53,8 +53,8 @@ func TestSHA1(t *testing.T) { ns := New() for i, test := range []struct { - in interface{} - expect interface{} + in any + expect any }{ {"Hello world, gophers!", "c8b5b0e33d408246e30f53e32b8f7627a7a649d4"}, {"Lorem ipsum dolor", "45f75b844be4d17b3394c6701768daf39419c99b"}, @@ -80,8 +80,8 @@ func TestSHA256(t *testing.T) { ns := New() for i, test := range []struct { - in interface{} - expect interface{} + in any + expect any }{ {"Hello world, gophers!", "6ec43b78da9669f50e4e422575c54bf87536954ccd58280219c393f2ce352b46"}, {"Lorem ipsum dolor", "9b3e1beb7053e0f900a674dd1c99aca3355e1275e1b03d3cb1bc977f5154e196"}, @@ -107,10 +107,10 @@ func TestHMAC(t *testing.T) { ns := New() for i, test := range []struct { - hash interface{} - key interface{} - msg interface{} - expect interface{} + hash any + key any + msg any + expect any }{ {"md5", "Secret key", "Hello world, gophers!", "36eb69b6bf2de96b6856fdee8bf89754"}, {"sha1", "Secret key", "Hello world, gophers!", "84a76647de6cd47ac6ae4258e3753f711172ce68"}, diff --git a/tpl/crypto/init.go b/tpl/crypto/init.go index 5ce2a4b5e..4b7cde2fa 100644 --- a/tpl/crypto/init.go +++ b/tpl/crypto/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.MD5, |