Skip to content

Commit

Permalink
Replace interface{} with any
Browse files Browse the repository at this point in the history
  • Loading branch information
rliebz committed Jan 2, 2025
1 parent bd08cb3 commit 3ed5638
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion appcli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func newMetaApp(cfgText []byte) (*cli.App, error) {
}

app := newSilentApp()
app.Metadata = make(map[string]interface{})
app.Metadata = make(map[string]any)
app.Metadata["tasks"] = make(map[string]*runner.Task)
app.Metadata["argsPassed"] = []string{}
app.Metadata["flagsPassed"] = make(map[string]string)
Expand Down
8 changes: 4 additions & 4 deletions appcli/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func init() { //nolint: gochecknoinits
// These are both used, so both must be overridden
cli.HelpPrinterCustom = wrapPrinter(cli.HelpPrinterCustom)
cli.HelpPrinter = func(w io.Writer, templ string, data interface{}) {
cli.HelpPrinter = func(w io.Writer, templ string, data any) {
cli.HelpPrinterCustom(w, templ, data, nil)
}

Expand Down Expand Up @@ -53,12 +53,12 @@ func ShowAppHelp(logger *ui.Logger, app *cli.App) {
cli.HelpPrinter(logger.Stdout, cli.AppHelpTemplate, app)
}

type helpPrinterCustom = func(io.Writer, string, interface{}, map[string]interface{})
type helpPrinterCustom = func(io.Writer, string, any, map[string]any)

// helpPrinter includes the custom indent template function.
func wrapPrinter(p helpPrinterCustom) helpPrinterCustom {
return func(w io.Writer, tpl string, data interface{}, funcs map[string]interface{}) {
customFuncs := map[string]interface{}{
return func(w io.Writer, tpl string, data any, funcs map[string]any) {
customFuncs := map[string]any{
"indent": func(spaces int, text string) string {
padding := strings.Repeat(" ", spaces)
return padding + strings.ReplaceAll(text, "\n", "\n"+padding)
Expand Down
2 changes: 1 addition & 1 deletion marshal/interpolate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var escSeq = []byte("{UNLIKELY_ESCAPE_SEQUENCE}")

// Interpolate an arbitrary YAML-marshallable interface.
func Interpolate(i interface{}, values map[string]string) error {
func Interpolate(i any, values map[string]string) error {
text, err := yaml.Marshal(i)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion marshal/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package marshal
type Slice[T any] []T

// UnmarshalYAML unmarshals an item or list of items always into a list.
func (sl *Slice[T]) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (sl *Slice[T]) UnmarshalYAML(unmarshal func(any) error) error {
var list []T
listCandidate := UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&list) },
Expand Down
2 changes: 1 addition & 1 deletion runner/arg.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (a *Arg) Evaluate() (string, error) {
type Args []*Arg

// UnmarshalYAML unmarshals an ordered set of options and assigns names.
func (a *Args) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (a *Args) UnmarshalYAML(unmarshal func(any) error) error {
var ms yaml.MapSlice
if err := unmarshal(&ms); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion runner/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Command struct {
}

// UnmarshalYAML allows strings to be interpreted as Do actions.
func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (c *Command) UnmarshalYAML(unmarshal func(any) error) error {
var str string
strCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&str) },
Expand Down
2 changes: 1 addition & 1 deletion runner/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestCommand_exec_helper(*testing.T) {
}
defer os.Exit(0)

fail := func(msg interface{}) {
fail := func(msg any) {
fmt.Fprintln(os.Stdout, msg)
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Config struct {
}

// UnmarshalYAML unmarshals and assigns names to options and tasks.
func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (c *Config) UnmarshalYAML(unmarshal func(any) error) error {
type configType Config // Use new type to avoid recursion
if err := unmarshal((*configType)(c)); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion runner/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func assertOptionsEqualUnordered(t *testing.T, a, b []*Option) {
return
}

bMap := make(map[*Option]interface{})
bMap := make(map[*Option]any)
for _, val := range b {
bMap[val] = struct{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion runner/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func newCondFailError(msg string) error {
}

// newCondFailErrorf returns an error indicating a condition has failed.
func newCondFailErrorf(msg string, a ...interface{}) error {
func newCondFailErrorf(msg string, a ...any) error {
formatted := fmt.Sprintf(msg, a...)
return &conditionFailedError{formatted}
}
Expand Down
4 changes: 2 additions & 2 deletions runner/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (o *Option) Dependencies() []string {
}

// UnmarshalYAML ensures that the option definition is valid.
func (o *Option) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (o *Option) UnmarshalYAML(unmarshal func(any) error) error {
type optionType Option // Use new type to avoid recursion
if err := unmarshal((*optionType)(o)); err != nil {
return err
Expand Down Expand Up @@ -202,7 +202,7 @@ func (o *Option) cache(value string) {
type Options []*Option

// UnmarshalYAML unmarshals an ordered set of options and assigns names.
func (o *Options) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (o *Options) UnmarshalYAML(unmarshal func(any) error) error {
var ms yaml.MapSlice
if err := unmarshal(&ms); err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions runner/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func TestOption_Dependencies(t *testing.T) {
}

func beEqualUnordered[T comparable](a, b []T) ghost.Result {
aMap := make(map[T]interface{})
aMap := make(map[T]any)
for _, val := range a {
aMap[val] = struct{}{}
}

bMap := make(map[T]interface{})
bMap := make(map[T]any)
for _, val := range b {
bMap[val] = struct{}{}
}
Expand Down
2 changes: 1 addition & 1 deletion runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Run struct {
}

// UnmarshalYAML allows simple commands to represent run structs.
func (r *Run) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (r *Run) UnmarshalYAML(unmarshal func(any) error) error {
var cl marshal.Slice[*Command]
commandCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&cl) },
Expand Down
2 changes: 1 addition & 1 deletion runner/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type SubTask struct {
}

// UnmarshalYAML allows unmarshaling a string to represent the subtask name.
func (s *SubTask) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (s *SubTask) UnmarshalYAML(unmarshal func(any) error) error {
var name string
nameCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&name) },
Expand Down
2 changes: 1 addition & 1 deletion runner/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Task struct {
}

// UnmarshalYAML unmarshals and assigns names to options.
func (t *Task) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (t *Task) UnmarshalYAML(unmarshal func(any) error) error {
var includeTarget Task
includeCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error {
Expand Down
2 changes: 1 addition & 1 deletion runner/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (v *Value) commandValueOrDefault(ctx Context) (string, error) {

// UnmarshalYAML allows plain strings to represent a full struct. The value of
// the string is used as the Default field.
func (v *Value) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (v *Value) UnmarshalYAML(unmarshal func(any) error) error {
var valueString string
stringCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&valueString) },
Expand Down
4 changes: 2 additions & 2 deletions runner/when.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type When struct {
}

// UnmarshalYAML warns about deprecated features.
func (w *When) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (w *When) UnmarshalYAML(unmarshal func(any) error) error {
var equal marshal.Slice[string]
slCandidate := marshal.UnmarshalCandidate{
Unmarshal: func() error { return unmarshal(&equal) },
Expand Down Expand Up @@ -324,7 +324,7 @@ func validateEquality(
type WhenList marshal.Slice[When]

// UnmarshalYAML allows single items to be used as lists.
func (l *WhenList) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (l *WhenList) UnmarshalYAML(unmarshal func(any) error) error {
return (*marshal.Slice[When])(l).UnmarshalYAML(unmarshal)
}

Expand Down
14 changes: 7 additions & 7 deletions ui/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Noop() *Logger {
}

// Println prints a line directly.
func (l *Logger) Println(a ...interface{}) {
func (l *Logger) Println(a ...any) {
if l.Verbosity <= VerbosityLevelSilent {
return
}
Expand All @@ -54,7 +54,7 @@ func (l *Logger) Println(a ...interface{}) {
}

// Debug prints debug information.
func (l *Logger) Debug(a ...interface{}) {
func (l *Logger) Debug(a ...any) {
if l.Verbosity < VerbosityLevelVerbose {
return
}
Expand All @@ -63,7 +63,7 @@ func (l *Logger) Debug(a ...interface{}) {
}

// Info prints normal application information.
func (l *Logger) Info(a ...interface{}) {
func (l *Logger) Info(a ...any) {
if l.Verbosity <= VerbosityLevelQuiet {
return
}
Expand All @@ -72,7 +72,7 @@ func (l *Logger) Info(a ...interface{}) {
}

// Warn prints at the warning level.
func (l *Logger) Warn(a ...interface{}) {
func (l *Logger) Warn(a ...any) {
if l.Verbosity <= VerbosityLevelQuiet {
return
}
Expand All @@ -81,7 +81,7 @@ func (l *Logger) Warn(a ...interface{}) {
}

// Error prints application errors.
func (l *Logger) Error(a ...interface{}) {
func (l *Logger) Error(a ...any) {
if l.Verbosity <= VerbosityLevelSilent {
return
}
Expand All @@ -90,7 +90,7 @@ func (l *Logger) Error(a ...interface{}) {
}

// Deprecate prints deprecation warnings no more than once.
func (l *Logger) Deprecate(a ...interface{}) {
func (l *Logger) Deprecate(a ...any) {
if l.Verbosity <= VerbosityLevelQuiet {
return
}
Expand All @@ -109,7 +109,7 @@ func (l *Logger) Deprecate(a ...interface{}) {
fmt.Fprintln(l.Stderr)
}

func (l *Logger) logInStyle(title string, f formatter, a ...interface{}) {
func (l *Logger) logInStyle(title string, f formatter, a ...any) {
messages := make([]string, 0, len(a))
for _, message := range a {
messages = append(messages, fmt.Sprint(message))
Expand Down
4 changes: 2 additions & 2 deletions ui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ var (
yellow = newFormatter(color.FgYellow)
)

type formatter func(a ...interface{}) string
type formatter func(a ...any) string

func newFormatter(value ...color.Attribute) formatter {
return func(a ...interface{}) string {
return func(a ...any) string {
return color.New(value...).SprintFunc()(a...)
}
}
Expand Down

0 comments on commit 3ed5638

Please sign in to comment.