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/internal | |
parent | 423594e03a906ef4150f433666ff588b022c3c92 (diff) |
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/internal')
-rw-r--r-- | tpl/internal/go_templates/texttemplate/hugo_template.go | 6 | ||||
-rw-r--r-- | tpl/internal/resourcehelpers/helpers.go | 6 | ||||
-rw-r--r-- | tpl/internal/templatefuncsRegistry.go | 8 |
3 files changed, 10 insertions, 10 deletions
diff --git a/tpl/internal/go_templates/texttemplate/hugo_template.go b/tpl/internal/go_templates/texttemplate/hugo_template.go index 41b43887d..dab5a05a3 100644 --- a/tpl/internal/go_templates/texttemplate/hugo_template.go +++ b/tpl/internal/go_templates/texttemplate/hugo_template.go @@ -48,7 +48,7 @@ type ExecHelper interface { // Executer executes a given template. type Executer interface { - ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data interface{}) error + ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data any) error } type executer struct { @@ -72,7 +72,7 @@ const ( ) // Note: The context is currently not fully implemeted in Hugo. This is a work in progress. -func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data interface{}) error { +func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Writer, data any) error { tmpl, err := p.Prepare() if err != nil { return err @@ -101,7 +101,7 @@ func (t *executer) ExecuteWithContext(ctx context.Context, p Preparer, wr io.Wri return tmpl.executeWithState(state, value) } -func (t *executer) Execute(p Preparer, wr io.Writer, data interface{}) error { +func (t *executer) Execute(p Preparer, wr io.Writer, data any) error { tmpl, err := p.Prepare() if err != nil { return err diff --git a/tpl/internal/resourcehelpers/helpers.go b/tpl/internal/resourcehelpers/helpers.go index 4f8b7539a..d1c9bbb75 100644 --- a/tpl/internal/resourcehelpers/helpers.go +++ b/tpl/internal/resourcehelpers/helpers.go @@ -26,7 +26,7 @@ import ( ) // We allow string or a map as the first argument in some cases. -func ResolveIfFirstArgIsString(args []interface{}) (resources.ResourceTransformer, string, bool) { +func ResolveIfFirstArgIsString(args []any) (resources.ResourceTransformer, string, bool) { if len(args) != 2 { return nil, "", false } @@ -41,7 +41,7 @@ func ResolveIfFirstArgIsString(args []interface{}) (resources.ResourceTransforme } // This roundabout way of doing it is needed to get both pipeline behaviour and options as arguments. -func ResolveArgs(args []interface{}) (resources.ResourceTransformer, map[string]interface{}, error) { +func ResolveArgs(args []any) (resources.ResourceTransformer, map[string]any, error) { if len(args) == 0 { return nil, nil, errors.New("no Resource provided in transformation") } @@ -56,7 +56,7 @@ func ResolveArgs(args []interface{}) (resources.ResourceTransformer, map[string] r, ok := args[1].(resources.ResourceTransformer) if !ok { - if _, ok := args[1].(map[string]interface{}); !ok { + if _, ok := args[1].(map[string]any); !ok { return nil, nil, fmt.Errorf("no Resource provided in transformation") } return nil, nil, fmt.Errorf("type %T not supported in Resource transformations", args[0]) diff --git a/tpl/internal/templatefuncsRegistry.go b/tpl/internal/templatefuncsRegistry.go index fe5dfe7ca..d06b55b4d 100644 --- a/tpl/internal/templatefuncsRegistry.go +++ b/tpl/internal/templatefuncsRegistry.go @@ -49,7 +49,7 @@ type TemplateFuncsNamespace struct { Name string // This is the method receiver. - Context func(v ...interface{}) (interface{}, error) + Context func(v ...any) (any, error) // Additional info, aliases and examples, per method name. MethodMappings map[string]TemplateFuncMethodMapping @@ -59,7 +59,7 @@ type TemplateFuncsNamespace struct { type TemplateFuncsNamespaces []*TemplateFuncsNamespace // AddMethodMapping adds a method to a template function namespace. -func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string) { +func (t *TemplateFuncsNamespace) AddMethodMapping(m any, aliases []string, examples [][2]string) { if t.MethodMappings == nil { t.MethodMappings = make(map[string]TemplateFuncMethodMapping) } @@ -88,7 +88,7 @@ func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []strin // TemplateFuncMethodMapping represents a mapping of functions to methods for a // given namespace. type TemplateFuncMethodMapping struct { - Method interface{} + Method any // Any template funcs aliases. This is mainly motivated by keeping // backwards compatibility, but some new template funcs may also make @@ -104,7 +104,7 @@ type TemplateFuncMethodMapping struct { Examples [][2]string } -func methodToName(m interface{}) string { +func methodToName(m any) string { name := runtime.FuncForPC(reflect.ValueOf(m).Pointer()).Name() name = filepath.Ext(name) name = strings.TrimPrefix(name, ".") |