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/path | |
parent | 423594e03a906ef4150f433666ff588b022c3c92 (diff) |
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/path')
-rw-r--r-- | tpl/path/init.go | 2 | ||||
-rw-r--r-- | tpl/path/path.go | 14 | ||||
-rw-r--r-- | tpl/path/path_test.go | 28 |
3 files changed, 22 insertions, 22 deletions
diff --git a/tpl/path/init.go b/tpl/path/init.go index 07f20d717..c67d94866 100644 --- a/tpl/path/init.go +++ b/tpl/path/init.go @@ -29,7 +29,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.Split, diff --git a/tpl/path/path.go b/tpl/path/path.go index ec50cff79..d334dd906 100644 --- a/tpl/path/path.go +++ b/tpl/path/path.go @@ -52,7 +52,7 @@ func (df DirFile) String() string { // it is empty if there is no dot. // The input path is passed into filepath.ToSlash converting any Windows slashes // to forward slashes. -func (ns *Namespace) Ext(path interface{}) (string, error) { +func (ns *Namespace) Ext(path any) (string, error) { spath, err := cast.ToStringE(path) if err != nil { return "", err @@ -70,7 +70,7 @@ func (ns *Namespace) Ext(path interface{}) (string, error) { // slash. // The input path is passed into filepath.ToSlash converting any Windows slashes // to forward slashes. -func (ns *Namespace) Dir(path interface{}) (string, error) { +func (ns *Namespace) Dir(path any) (string, error) { spath, err := cast.ToStringE(path) if err != nil { return "", err @@ -85,7 +85,7 @@ func (ns *Namespace) Dir(path interface{}) (string, error) { // If the path consists entirely of slashes, Base returns "/". // The input path is passed into filepath.ToSlash converting any Windows slashes // to forward slashes. -func (ns *Namespace) Base(path interface{}) (string, error) { +func (ns *Namespace) Base(path any) (string, error) { spath, err := cast.ToStringE(path) if err != nil { return "", err @@ -101,7 +101,7 @@ func (ns *Namespace) Base(path interface{}) (string, error) { // The input path is passed into filepath.ToSlash converting any Windows slashes // to forward slashes. // The returned values have the property that path = dir+file. -func (ns *Namespace) Split(path interface{}) (DirFile, error) { +func (ns *Namespace) Split(path any) (DirFile, error) { spath, err := cast.ToStringE(path) if err != nil { return DirFile{}, err @@ -118,7 +118,7 @@ func (ns *Namespace) Split(path interface{}) (DirFile, error) { // to forward slashes. // The result is Cleaned; in particular, // all empty strings are ignored. -func (ns *Namespace) Join(elements ...interface{}) (string, error) { +func (ns *Namespace) Join(elements ...any) (string, error) { var pathElements []string for _, elem := range elements { switch v := elem.(type) { @@ -126,7 +126,7 @@ func (ns *Namespace) Join(elements ...interface{}) (string, error) { for _, e := range v { pathElements = append(pathElements, filepath.ToSlash(e)) } - case []interface{}: + case []any: for _, e := range v { elemStr, err := cast.ToStringE(e) if err != nil { @@ -147,7 +147,7 @@ func (ns *Namespace) Join(elements ...interface{}) (string, error) { // Clean replaces the separators used with standard slashes and then // extraneous slashes are removed. -func (ns *Namespace) Clean(path interface{}) (string, error) { +func (ns *Namespace) Clean(path any) (string, error) { spath, err := cast.ToStringE(path) if err != nil { diff --git a/tpl/path/path_test.go b/tpl/path/path_test.go index d4a438b5c..c9f8469e7 100644 --- a/tpl/path/path_test.go +++ b/tpl/path/path_test.go @@ -31,8 +31,8 @@ func TestBase(t *testing.T) { c := qt.New(t) for _, test := range []struct { - path interface{} - expect interface{} + path any + expect any }{ {filepath.FromSlash(`foo/bar.txt`), `bar.txt`}, {filepath.FromSlash(`foo/bar/txt `), `txt `}, @@ -61,8 +61,8 @@ func TestDir(t *testing.T) { c := qt.New(t) for _, test := range []struct { - path interface{} - expect interface{} + path any + expect any }{ {filepath.FromSlash(`foo/bar.txt`), `foo`}, {filepath.FromSlash(`foo/bar/txt `), `foo/bar`}, @@ -91,8 +91,8 @@ func TestExt(t *testing.T) { c := qt.New(t) for _, test := range []struct { - path interface{} - expect interface{} + path any + expect any }{ {filepath.FromSlash(`foo/bar.json`), `.json`}, {`foo.bar.txt `, `.txt `}, @@ -119,21 +119,21 @@ func TestJoin(t *testing.T) { c := qt.New(t) for _, test := range []struct { - elements interface{} - expect interface{} + elements any + expect any }{ { []string{"", "baz", filepath.FromSlash(`foo/bar.txt`)}, `baz/foo/bar.txt`, }, { - []interface{}{"", "baz", DirFile{"big", "john"}, filepath.FromSlash(`foo/bar.txt`)}, + []any{"", "baz", DirFile{"big", "john"}, filepath.FromSlash(`foo/bar.txt`)}, `baz/big|john/foo/bar.txt`, }, {nil, ""}, // errors {tstNoStringer{}, false}, - {[]interface{}{"", tstNoStringer{}}, false}, + {[]any{"", tstNoStringer{}}, false}, } { result, err := ns.Join(test.elements) @@ -153,8 +153,8 @@ func TestSplit(t *testing.T) { c := qt.New(t) for _, test := range []struct { - path interface{} - expect interface{} + path any + expect any }{ {filepath.FromSlash(`foo/bar.txt`), DirFile{`foo/`, `bar.txt`}}, {filepath.FromSlash(`foo/bar/txt `), DirFile{`foo/bar/`, `txt `}}, @@ -181,8 +181,8 @@ func TestClean(t *testing.T) { c := qt.New(t) for _, test := range []struct { - path interface{} - expect interface{} + path any + expect any }{ {filepath.FromSlash(`foo/bar.txt`), `foo/bar.txt`}, {filepath.FromSlash(`foo/bar/txt`), `foo/bar/txt`}, |