Skip to content

Commit

Permalink
Workaround: use strings.Replace instead of fmt.Sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Apr 19, 2023
1 parent a30a9b0 commit 1852e7c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/pkg/agent/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"

"github.com/otiai10/copy"

Expand Down Expand Up @@ -86,8 +87,10 @@ func Install(cfgFile, topPath string) error {
errors.M("destination", paths.ShellWrapperPath))
}
} else {
//nolint: govet,staticcheck // the first argument to fmt.Sprintf is a constant containing one formatting directive.
shellWrapper := fmt.Sprintf(paths.ShellWrapper, topPath)
// We use strings.Replace instead of fmt.Sprintf here because, with the
// latter, govet throws a false positive error here: "fmt.Sprintf call has
// arguments but no formatting directives".
shellWrapper := strings.Replace(paths.ShellWrapper, "%s", topPath, -1)
err = os.WriteFile(paths.ShellWrapperPath, []byte(shellWrapper), 0755)
if err != nil {
return errors.New(
Expand Down

0 comments on commit 1852e7c

Please sign in to comment.