summaryrefslogtreecommitdiffstats
path: root/tpl/os
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/os
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'tpl/os')
-rw-r--r--tpl/os/init.go2
-rw-r--r--tpl/os/os.go10
-rw-r--r--tpl/os/os_test.go6
3 files changed, 9 insertions, 9 deletions
diff --git a/tpl/os/init.go b/tpl/os/init.go
index c25d63d56..cd9e370cd 100644
--- a/tpl/os/init.go
+++ b/tpl/os/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.Getenv,
diff --git a/tpl/os/os.go b/tpl/os/os.go
index 5abc03c68..4fa470952 100644
--- a/tpl/os/os.go
+++ b/tpl/os/os.go
@@ -53,7 +53,7 @@ type Namespace struct {
// Getenv retrieves the value of the environment variable named by the key.
// It returns the value, which will be empty if the variable is not present.
-func (ns *Namespace) Getenv(key interface{}) (string, error) {
+func (ns *Namespace) Getenv(key any) (string, error) {
skey, err := cast.ToStringE(key)
if err != nil {
return "", nil
@@ -85,7 +85,7 @@ func readFile(fs afero.Fs, filename string) (string, error) {
// ReadFile reads the file named by filename relative to the configured WorkingDir.
// It returns the contents as a string.
// There is an upper size limit set at 1 megabytes.
-func (ns *Namespace) ReadFile(i interface{}) (string, error) {
+func (ns *Namespace) ReadFile(i any) (string, error) {
s, err := cast.ToStringE(i)
if err != nil {
return "", err
@@ -99,7 +99,7 @@ func (ns *Namespace) ReadFile(i interface{}) (string, error) {
}
// ReadDir lists the directory contents relative to the configured WorkingDir.
-func (ns *Namespace) ReadDir(i interface{}) ([]_os.FileInfo, error) {
+func (ns *Namespace) ReadDir(i any) ([]_os.FileInfo, error) {
path, err := cast.ToStringE(i)
if err != nil {
return nil, err
@@ -114,7 +114,7 @@ func (ns *Namespace) ReadDir(i interface{}) ([]_os.FileInfo, error) {
}
// FileExists checks whether a file exists under the given path.
-func (ns *Namespace) FileExists(i interface{}) (bool, error) {
+func (ns *Namespace) FileExists(i any) (bool, error) {
path, err := cast.ToStringE(i)
if err != nil {
return false, err
@@ -133,7 +133,7 @@ func (ns *Namespace) FileExists(i interface{}) (bool, error) {
}
// Stat returns the os.FileInfo structure describing file.
-func (ns *Namespace) Stat(i interface{}) (_os.FileInfo, error) {
+func (ns *Namespace) Stat(i any) (_os.FileInfo, error) {
path, err := cast.ToStringE(i)
if err != nil {
return nil, err
diff --git a/tpl/os/os_test.go b/tpl/os/os_test.go
index 59491e97c..98befa061 100644
--- a/tpl/os/os_test.go
+++ b/tpl/os/os_test.go
@@ -34,7 +34,7 @@ func TestReadFile(t *testing.T) {
for _, test := range []struct {
filename string
- expect interface{}
+ expect any
}{
{filepath.FromSlash("/f/f1.txt"), "f1-content"},
{filepath.FromSlash("f/f1.txt"), "f1-content"},
@@ -64,7 +64,7 @@ func TestFileExists(t *testing.T) {
for _, test := range []struct {
filename string
- expect interface{}
+ expect any
}{
{filepath.FromSlash("/f/f1.txt"), true},
{filepath.FromSlash("f/f1.txt"), true},
@@ -91,7 +91,7 @@ func TestStat(t *testing.T) {
for _, test := range []struct {
filename string
- expect interface{}
+ expect any
}{
{filepath.FromSlash("/f/f1.txt"), int64(10)},
{filepath.FromSlash("f/f1.txt"), int64(10)},