diff --git a/.goreleaser.yml b/.goreleaser.yml index edf9277d..2a272d66 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -22,15 +22,14 @@ builds: - GOPROXY=https://proxy.golang.org - GOSUMDB=sum.golang.org main: ./mockgen/ -archive: - format: tar.gz - wrap_in_directory: true - name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' - files: - - LICENSE - - README.md + +archives: + - format: tar.gz + wrap_in_directory: true + files: + - LICENSE + - README.md checksum: - name_template: '{{ .Binary }}-{{ .Version }}-checksums.txt' snapshot: name_template: "snap-{{ .Commit }}" changelog: diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go index 1f14aa7c..33c833c6 100644 --- a/mockgen/mockgen.go +++ b/mockgen/mockgen.go @@ -45,6 +45,12 @@ const ( gomockImportPath = "github.com/golang/mock/gomock" ) +var ( + version = "" + commit = "none" + date = "unknown" +) + var ( source = flag.String("source", "", "(source mode) Input Go source file; enables source mode.") destination = flag.String("destination", "", "Output file; defaults to stdout.") @@ -55,14 +61,14 @@ var ( copyrightFile = flag.String("copyright_file", "", "Copyright file used to add copyright header") debugParser = flag.Bool("debug_parser", false, "Print out parser results only.") - version = flag.Bool("version", false, "Print version.") + showVersion = flag.Bool("version", false, "Print version.") ) func main() { flag.Usage = usage flag.Parse() - if *version { + if *showVersion { printVersion() return } @@ -621,3 +627,11 @@ func lookupPackageName(importPath string) (string, bool) { } return pkg.Name, true } + +func printVersion() { + if version != "" { + fmt.Printf("v%s\nCommit: %s\nDate: %s\n", version, commit, date) + } else { + printModuleVersion() + } +} diff --git a/mockgen/version.1.11.go b/mockgen/version.1.11.go index e47183d2..e6b25db2 100644 --- a/mockgen/version.1.11.go +++ b/mockgen/version.1.11.go @@ -20,7 +20,7 @@ import ( "log" ) -func printVersion() { +func printModuleVersion() { log.Printf("No version information is available for Mockgen compiled with " + "version 1.11") } diff --git a/mockgen/version.1.12.go b/mockgen/version.1.12.go index 3cc2ad83..ad121ae6 100644 --- a/mockgen/version.1.12.go +++ b/mockgen/version.1.12.go @@ -23,7 +23,7 @@ import ( "runtime/debug" ) -func printVersion() { +func printModuleVersion() { if bi, exists := debug.ReadBuildInfo(); exists { fmt.Println(bi.Main.Version) } else {
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: