refactor: enable gofmt linter and fix all issues

- also rewrite 'interface{}' as 'any'
This commit is contained in:
Pete Davison
2023-03-30 20:03:59 +00:00
committed by Andrey Nering
parent a6d57496c2
commit aab51c331f
12 changed files with 41 additions and 36 deletions

View File

@@ -12,8 +12,8 @@ import (
func TestPreconditionParse(t *testing.T) {
tests := []struct {
content string
v interface{}
expected interface{}
v any
expected any
}{
{
"test -f foo.txt",

View File

@@ -24,8 +24,8 @@ vars:
)
tests := []struct {
content string
v interface{}
expected interface{}
v any
expected any
}{
{
yamlCmd,
@@ -38,8 +38,8 @@ vars:
&taskfile.Cmd{Task: "another-task", Vars: &taskfile.Vars{
Keys: []string{"PARAM1", "PARAM2"},
Mapping: map[string]taskfile.Var{
"PARAM1": taskfile.Var{Static: "VALUE1"},
"PARAM2": taskfile.Var{Static: "VALUE2"},
"PARAM1": {Static: "VALUE1"},
"PARAM2": {Static: "VALUE2"},
},
}},
},
@@ -54,7 +54,7 @@ vars:
&taskfile.Cmd{Task: "some_task", Vars: &taskfile.Vars{
Keys: []string{"PARAM1"},
Mapping: map[string]taskfile.Var{
"PARAM1": taskfile.Var{Static: "var"},
"PARAM1": {Static: "var"},
},
}, Defer: true},
},
@@ -69,8 +69,8 @@ vars:
&taskfile.Dep{Task: "another-task", Vars: &taskfile.Vars{
Keys: []string{"PARAM1", "PARAM2"},
Mapping: map[string]taskfile.Var{
"PARAM1": taskfile.Var{Static: "VALUE1"},
"PARAM2": taskfile.Var{Static: "VALUE2"},
"PARAM1": {Static: "VALUE1"},
"PARAM2": {Static: "VALUE2"},
},
}},
},

View File

@@ -82,8 +82,8 @@ func (vs *Vars) Range(yield func(key string, value Var) error) error {
// ToCacheMap converts Vars to a map containing only the static
// variables
func (vs *Vars) ToCacheMap() (m map[string]interface{}) {
m = make(map[string]interface{}, vs.Len())
func (vs *Vars) ToCacheMap() (m map[string]any) {
m = make(map[string]any, vs.Len())
_ = vs.Range(func(k string, v Var) error {
if v.Sh != "" {
// Dynamic variable is not yet resolved; trigger
@@ -112,7 +112,7 @@ func (vs *Vars) Len() int {
// Var represents either a static or dynamic variable.
type Var struct {
Static string
Live interface{}
Live any
Sh string
Dir string
}