summaryrefslogtreecommitdiffstats
path: root/tpl/urls
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/urls
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/urls')
-rw-r--r--tpl/urls/init.go2
-rw-r--r--tpl/urls/urls.go28
-rw-r--r--tpl/urls/urls_test.go4
3 files changed, 17 insertions, 17 deletions
diff --git a/tpl/urls/init.go b/tpl/urls/init.go
index 0a97045e2..3597e87c5 100644
--- a/tpl/urls/init.go
+++ b/tpl/urls/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.AbsURL,
diff --git a/tpl/urls/urls.go b/tpl/urls/urls.go
index 1bba636ad..e07106261 100644
--- a/tpl/urls/urls.go
+++ b/tpl/urls/urls.go
@@ -41,7 +41,7 @@ type Namespace struct {
}
// AbsURL takes a given string and converts it to an absolute URL.
-func (ns *Namespace) AbsURL(a interface{}) (template.HTML, error) {
+func (ns *Namespace) AbsURL(a any) (template.HTML, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", nil
@@ -52,7 +52,7 @@ func (ns *Namespace) AbsURL(a interface{}) (template.HTML, error) {
// Parse parses rawurl into a URL structure. The rawurl may be relative or
// absolute.
-func (ns *Namespace) Parse(rawurl interface{}) (*url.URL, error) {
+func (ns *Namespace) Parse(rawurl any) (*url.URL, error) {
s, err := cast.ToStringE(rawurl)
if err != nil {
return nil, _errors.Wrap(err, "Error in Parse")
@@ -63,7 +63,7 @@ func (ns *Namespace) Parse(rawurl interface{}) (*url.URL, error) {
// RelURL takes a given string and prepends the relative path according to a
// page's position in the project directory structure.
-func (ns *Namespace) RelURL(a interface{}) (template.HTML, error) {
+func (ns *Namespace) RelURL(a any) (template.HTML, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", nil
@@ -73,7 +73,7 @@ func (ns *Namespace) RelURL(a interface{}) (template.HTML, error) {
}
// URLize returns the given argument formatted as URL.
-func (ns *Namespace) URLize(a interface{}) (string, error) {
+func (ns *Namespace) URLize(a any) (string, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", nil
@@ -82,7 +82,7 @@ func (ns *Namespace) URLize(a interface{}) (string, error) {
}
// Anchorize creates sanitized anchor names that are compatible with Blackfriday.
-func (ns *Namespace) Anchorize(a interface{}) (string, error) {
+func (ns *Namespace) Anchorize(a any) (string, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", nil
@@ -91,7 +91,7 @@ func (ns *Namespace) Anchorize(a interface{}) (string, error) {
}
// Ref returns the absolute URL path to a given content item.
-func (ns *Namespace) Ref(in interface{}, args interface{}) (template.HTML, error) {
+func (ns *Namespace) Ref(in any, args any) (template.HTML, error) {
p, ok := in.(urls.RefLinker)
if !ok {
return "", errors.New("invalid Page received in Ref")
@@ -105,7 +105,7 @@ func (ns *Namespace) Ref(in interface{}, args interface{}) (template.HTML, error
}
// RelRef returns the relative URL path to a given content item.
-func (ns *Namespace) RelRef(in interface{}, args interface{}) (template.HTML, error) {
+func (ns *Namespace) RelRef(in any, args any) (template.HTML, error) {
p, ok := in.(urls.RefLinker)
if !ok {
return "", errors.New("invalid Page received in RelRef")
@@ -119,22 +119,22 @@ func (ns *Namespace) RelRef(in interface{}, args interface{}) (template.HTML, er
return template.HTML(s), err
}
-func (ns *Namespace) refArgsToMap(args interface{}) (map[string]interface{}, error) {
+func (ns *Namespace) refArgsToMap(args any) (map[string]any, error) {
var (
s string
of string
)
v := args
- if _, ok := v.([]interface{}); ok {
+ if _, ok := v.([]any); ok {
v = cast.ToStringSlice(v)
}
switch v := v.(type) {
- case map[string]interface{}:
+ case map[string]any:
return v, nil
case map[string]string:
- m := make(map[string]interface{})
+ m := make(map[string]any)
for k, v := range v {
m[k] = v
}
@@ -157,7 +157,7 @@ func (ns *Namespace) refArgsToMap(args interface{}) (map[string]interface{}, err
}
- return map[string]interface{}{
+ return map[string]any{
"path": s,
"outputFormat": of,
}, nil
@@ -165,7 +165,7 @@ func (ns *Namespace) refArgsToMap(args interface{}) (map[string]interface{}, err
// RelLangURL takes a given string and prepends the relative path according to a
// page's position in the project directory structure and the current language.
-func (ns *Namespace) RelLangURL(a interface{}) (template.HTML, error) {
+func (ns *Namespace) RelLangURL(a any) (template.HTML, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", err
@@ -177,7 +177,7 @@ func (ns *Namespace) RelLangURL(a interface{}) (template.HTML, error) {
// AbsLangURL takes a given string and converts it to an absolute URL according
// to a page's position in the project directory structure and the current
// language.
-func (ns *Namespace) AbsLangURL(a interface{}) (template.HTML, error) {
+func (ns *Namespace) AbsLangURL(a any) (template.HTML, error) {
s, err := cast.ToStringE(a)
if err != nil {
return "", err
diff --git a/tpl/urls/urls_test.go b/tpl/urls/urls_test.go
index 23068c243..73b5cd141 100644
--- a/tpl/urls/urls_test.go
+++ b/tpl/urls/urls_test.go
@@ -34,8 +34,8 @@ func TestParse(t *testing.T) {
c := qt.New(t)
for _, test := range []struct {
- rawurl interface{}
- expect interface{}
+ rawurl any
+ expect any
}{
{
"http://www.google.com",