Skip to content

Commit

Permalink
MockGen header comment: trim .exe suffix on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
craig65535 committed Nov 10, 2023
1 parent 7fb6390 commit f4721e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mockgen/mockgen.go
Expand Up @@ -31,6 +31,7 @@ import (
"os/exec"
"path"
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -316,7 +317,11 @@ func (g *generator) Generate(pkg *model.Package, outputPkgName string, outputPac
g.p("// Generated by this command:")
g.p("//")
// only log the name of the executable, not the full path
g.p("//\t%v", strings.Join(append([]string{filepath.Base(os.Args[0])}, os.Args[1:]...), " "))
name := filepath.Base(os.Args[0])
if runtime.GOOS == "windows" && strings.HasSuffix(name, ".exe") {
name = strings.TrimSuffix(name, ".exe")
}
g.p("//\t%v", strings.Join(append([]string{name}, os.Args[1:]...), " "))
g.p("//")

// Get all required imports, and generate unique names for them all.
Expand Down

0 comments on commit f4721e4

Please sign in to comment.