Skip to content

Commit

Permalink
Fix non-constant format string errors with Go 1.24 (#1745)
Browse files Browse the repository at this point in the history
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 <salimma@fedoraproject.org>
  • Loading branch information
michel-slm authored Feb 5, 2025
1 parent 2250723 commit bd2497a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/dsl/cst/builtin_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package cst

import (
"errors"
"fmt"

"github.com/johnkerl/miller/v6/pkg/bifs"
Expand Down Expand Up @@ -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,
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/dsl/cst/lvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package cst

import (
"errors"
"fmt"
"os"

Expand Down Expand Up @@ -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),
)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/dsl/cst/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package cst

import (
"container/list"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd2497a

Please sign in to comment.