From bd2497a2854de5aa87928b669ef65839b972dde7 Mon Sep 17 00:00:00 2001 From: Michel Lind Date: Wed, 5 Feb 2025 14:32:23 +0100 Subject: [PATCH] Fix non-constant format string errors with Go 1.24 (#1745) Use `errors.New` instead of `fmt.Errorf` and `fmt.Fprint` instead of `fmt.Fprintf` if a non-constant string is used Signed-off-by: Michel Lind --- pkg/dsl/cst/builtin_functions.go | 3 ++- pkg/dsl/cst/lvalues.go | 3 ++- pkg/dsl/cst/root.go | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/dsl/cst/builtin_functions.go b/pkg/dsl/cst/builtin_functions.go index e3558d1cd..12c16ea45 100644 --- a/pkg/dsl/cst/builtin_functions.go +++ b/pkg/dsl/cst/builtin_functions.go @@ -5,6 +5,7 @@ package cst import ( + "errors" "fmt" "github.com/johnkerl/miller/v6/pkg/bifs" @@ -78,7 +79,7 @@ func (root *RootNode) BuildMultipleArityFunctionCallsiteNode( return root.BuildTernaryFunctionCallsiteNode(astNode, builtinFunctionInfo) } - return nil, fmt.Errorf( + return nil, errors.New( "at CST BuildMultipleArityFunctionCallsiteNode: function name not found: " + builtinFunctionInfo.name, ) diff --git a/pkg/dsl/cst/lvalues.go b/pkg/dsl/cst/lvalues.go index b680644cb..799d8801e 100644 --- a/pkg/dsl/cst/lvalues.go +++ b/pkg/dsl/cst/lvalues.go @@ -6,6 +6,7 @@ package cst import ( + "errors" "fmt" "os" @@ -62,7 +63,7 @@ func (root *RootNode) BuildAssignableNode( return root.BuildEnvironmentVariableLvalueNode(astNode) } - return nil, fmt.Errorf( + return nil, errors.New( "at CST BuildAssignableNode: unhandled AST node " + string(astNode.Type), ) } diff --git a/pkg/dsl/cst/root.go b/pkg/dsl/cst/root.go index a1c5b0b99..e6d2de59a 100644 --- a/pkg/dsl/cst/root.go +++ b/pkg/dsl/cst/root.go @@ -7,6 +7,7 @@ package cst import ( "container/list" + "errors" "fmt" "os" "strings" @@ -163,7 +164,7 @@ func (root *RootNode) IngestAST( err = nil if ast.RootNode == nil { - return hadWarnings, fmt.Errorf("cannot build CST from nil AST root") + return hadWarnings, errors.New("cannot build CST from nil AST root") } // Check for things that are syntax errors but not done in the AST for @@ -417,7 +418,7 @@ func (root *RootNode) resolveSubroutineCallsites() error { return err } if uds == nil { - return fmt.Errorf("mlr: subroutine name not found: " + subroutineName) + return errors.New("mlr: subroutine name not found: " + subroutineName) } unresolvedSubroutineCallsite.uds = uds