From c97c001fc428eafa7c4d2baaca3a9fe4261b97ee Mon Sep 17 00:00:00 2001 From: "Singh, NileshKumar" Date: Sat, 12 Jun 2021 19:48:37 +0530 Subject: [PATCH] Add invocation args & mockgen version in generated code --- mockgen/mockgen.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go index 50487070..53d997eb 100644 --- a/mockgen/mockgen.go +++ b/mockgen/mockgen.go @@ -31,6 +31,7 @@ import ( "os/exec" "path" "path/filepath" + "runtime/debug" "sort" "strconv" "strings" @@ -279,6 +280,16 @@ 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:") + invocatedCmd := strings.Join(os.Args, " ") + g.p("// %v", invocatedCmd) + + if bi, exists := debug.ReadBuildInfo(); exists { + g.p("//") + g.p("// Mockgen version: %v", bi.Main.Version) + } g.p("") // Get all required imports, and generate unique names for them all.