Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Add invocation args & mockgen version in generated code #574

Closed
wants to merge 6 commits into from
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions mockgen/mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"os/exec"
"path"
"path/filepath"
"runtime/debug"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -279,6 +280,18 @@ func (g *generator) Generate(pkg *model.Package, outputPkgName string, outputPac
} else {
g.p("// Source: %v (interfaces: %v)", g.srcPackage, g.srcInterfaces)
}
g.p("//")

g.p("// Generated by this command:")
invokedArgs := strings.Join(os.Args, " ")
g.p("// %v", invokedArgs)

g.p("//")
if version != "" {
g.p("// Mockgen version: %s", version)
} else if bi, exists := debug.ReadBuildInfo(); exists {
g.p("// Mockgen version: %s", bi.Main.Version)
}
g.p("")

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