From 8947b662186116ddf41faa9d96a083575cc312ff Mon Sep 17 00:00:00 2001 From: "W. Michael Petullo" Date: Sun, 21 Dec 2025 12:17:04 -0600 Subject: [PATCH] Use constant format strings with Printf-like functions Recent versions of Go object to the use of non-constant variables a format strings. This commit fixes errors like this: cli.go:26:47: non-constant format string in call to fmt.Fprintf Signed-off-by: W. Michael Petullo --- internal/cli/cli.go | 2 +- unmarshaler.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cli/cli.go b/internal/cli/cli.go index 079b19e3..c0c50898 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -22,7 +22,7 @@ type Program struct { } func (p *Program) Execute() { - flag.Usage = func() { fmt.Fprintf(os.Stderr, p.Usage) } + flag.Usage = func() { fmt.Fprint(os.Stderr, p.Usage) } flag.Parse() os.Exit(p.main(flag.Args(), os.Stdin, os.Stdout, os.Stderr)) } diff --git a/unmarshaler.go b/unmarshaler.go index d0df35ec..047c8b43 100644 --- a/unmarshaler.go +++ b/unmarshaler.go @@ -1034,7 +1034,7 @@ func (d *decoder) unmarshalInteger(value *unstable.Node, v reflect.Value) error case reflect.Interface: r = reflect.ValueOf(i) default: - return unstable.NewParserError(d.p.Raw(value.Raw), d.typeMismatchString("integer", v.Type())) + return unstable.NewParserError(d.p.Raw(value.Raw), "%s", d.typeMismatchString("integer", v.Type())) } if !r.Type().AssignableTo(v.Type()) { @@ -1053,7 +1053,7 @@ func (d *decoder) unmarshalString(value *unstable.Node, v reflect.Value) error { case reflect.Interface: v.Set(reflect.ValueOf(string(value.Data))) default: - return unstable.NewParserError(d.p.Raw(value.Raw), d.typeMismatchString("string", v.Type())) + return unstable.NewParserError(d.p.Raw(value.Raw), "%s", d.typeMismatchString("string", v.Type())) } return nil