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

@@ -14,7 +14,7 @@ type StatusCheckable interface {
// SourcesCheckable defines any type that can check if the sources of a task are up-to-date.
type SourcesCheckable interface {
IsUpToDate(t *taskfile.Task) (bool, error)
Value(t *taskfile.Task) (interface{}, error)
Value(t *taskfile.Task) (any, error)
OnError(t *taskfile.Task) error
Kind() string
}

View File

@@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: checker.go
// Source: internal/fingerprint/checker.go
// Package fingerprint is a generated GoMock package.
package fingerprint
@@ -117,10 +117,10 @@ func (mr *MockSourcesCheckableMockRecorder) OnError(t interface{}) *gomock.Call
}
// Value mocks base method.
func (m *MockSourcesCheckable) Value(t *taskfile.Task) (interface{}, error) {
func (m *MockSourcesCheckable) Value(t *taskfile.Task) (any, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Value", t)
ret0, _ := ret[0].(interface{})
ret0, _ := ret[0].(any)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View File

@@ -68,7 +68,7 @@ func (checker *ChecksumChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
return oldMd5 == newMd5, nil
}
func (checker *ChecksumChecker) Value(t *taskfile.Task) (interface{}, error) {
func (checker *ChecksumChecker) Value(t *taskfile.Task) (any, error) {
return checker.checksum(t)
}

View File

@@ -10,7 +10,7 @@ func (NoneChecker) IsUpToDate(t *taskfile.Task) (bool, error) {
return false, nil
}
func (NoneChecker) Value(t *taskfile.Task) (interface{}, error) {
func (NoneChecker) Value(t *taskfile.Task) (any, error) {
return "", nil
}

View File

@@ -89,7 +89,7 @@ func (checker *TimestampChecker) Kind() string {
}
// Value implements the Checker Interface
func (checker *TimestampChecker) Value(t *taskfile.Task) (interface{}, error) {
func (checker *TimestampChecker) Value(t *taskfile.Task) (any, error) {
sources, err := globs(t.Dir, t.Sources)
if err != nil {
return time.Now(), err

View File

@@ -9,7 +9,7 @@ import (
)
type Color func() PrintFunc
type PrintFunc func(io.Writer, string, ...interface{})
type PrintFunc func(io.Writer, string, ...any)
func Default() PrintFunc {
return color.New(envColor("TASK_COLOR_RESET", color.Reset)).FprintfFunc()
@@ -56,14 +56,14 @@ type Logger struct {
}
// Outf prints stuff to STDOUT.
func (l *Logger) Outf(color Color, s string, args ...interface{}) {
func (l *Logger) Outf(color Color, s string, args ...any) {
l.FOutf(l.Stdout, color, s+"\n", args...)
}
// FOutf prints stuff to the given writer.
func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...interface{}) {
func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...any) {
if len(args) == 0 {
s, args = "%s", []interface{}{s}
s, args = "%s", []any{s}
}
if !l.Color {
color = Default
@@ -73,16 +73,16 @@ func (l *Logger) FOutf(w io.Writer, color Color, s string, args ...interface{})
}
// VerboseOutf prints stuff to STDOUT if verbose mode is enabled.
func (l *Logger) VerboseOutf(color Color, s string, args ...interface{}) {
func (l *Logger) VerboseOutf(color Color, s string, args ...any) {
if l.Verbose {
l.Outf(color, s, args...)
}
}
// Errf prints stuff to STDERR.
func (l *Logger) Errf(color Color, s string, args ...interface{}) {
func (l *Logger) Errf(color Color, s string, args ...any) {
if len(args) == 0 {
s, args = "%s", []interface{}{s}
s, args = "%s", []any{s}
}
if !l.Color {
color = Default
@@ -92,7 +92,7 @@ func (l *Logger) Errf(color Color, s string, args ...interface{}) {
}
// VerboseErrf prints stuff to STDERR if verbose mode is enabled.
func (l *Logger) VerboseErrf(color Color, s string, args ...interface{}) {
func (l *Logger) VerboseErrf(color Color, s string, args ...any) {
if l.Verbose {
l.Errf(color, s, args...)
}

View File

@@ -16,7 +16,7 @@ type Templater struct {
Vars *taskfile.Vars
RemoveNoValue bool
cacheMap map[string]interface{}
cacheMap map[string]any
err error
}