Skip to content

Commit

Permalink
MockGen header comment: trim .exe suffix on Windows (#119)
Browse files Browse the repository at this point in the history
To address #118

---------

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
  • Loading branch information
craig65535 and marten-seemann committed Nov 17, 2023
1 parent 857e269 commit 5b48f95
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" {
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 5b48f95

Please sign in to comment.