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

Commit 0188501

Browse files
author
Filip Nguyen
authoredFeb 5, 2020
Goreleaser (#394)
When publishing binaries using Goreleaser use build flags. Also remove custom archives and checksum name_templates because Goreleaser has reasonable defaults, see https://goreleaser.com/customization/#Archive
1 parent 41fe4f7 commit 0188501

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed
 

Diff for: ‎.goreleaser.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ builds:
2222
- GOPROXY=https://proxy.golang.org
2323
- GOSUMDB=sum.golang.org
2424
main: ./mockgen/
25-
archive:
26-
format: tar.gz
27-
wrap_in_directory: true
28-
name_template: '{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
29-
files:
30-
- LICENSE
31-
- README.md
25+
26+
archives:
27+
- format: tar.gz
28+
wrap_in_directory: true
29+
files:
30+
- LICENSE
31+
- README.md
3232
checksum:
33-
name_template: '{{ .Binary }}-{{ .Version }}-checksums.txt'
3433
snapshot:
3534
name_template: "snap-{{ .Commit }}"
3635
changelog:

Diff for: ‎mockgen/mockgen.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ const (
4545
gomockImportPath = "github.com/golang/mock/gomock"
4646
)
4747

48+
var (
49+
version = ""
50+
commit = "none"
51+
date = "unknown"
52+
)
53+
4854
var (
4955
source = flag.String("source", "", "(source mode) Input Go source file; enables source mode.")
5056
destination = flag.String("destination", "", "Output file; defaults to stdout.")
@@ -55,14 +61,14 @@ var (
5561
copyrightFile = flag.String("copyright_file", "", "Copyright file used to add copyright header")
5662

5763
debugParser = flag.Bool("debug_parser", false, "Print out parser results only.")
58-
version = flag.Bool("version", false, "Print version.")
64+
showVersion = flag.Bool("version", false, "Print version.")
5965
)
6066

6167
func main() {
6268
flag.Usage = usage
6369
flag.Parse()
6470

65-
if *version {
71+
if *showVersion {
6672
printVersion()
6773
return
6874
}
@@ -633,3 +639,11 @@ func lookupPackageName(importPath string) (string, bool) {
633639
}
634640
return pkg.Name, true
635641
}
642+
643+
func printVersion() {
644+
if version != "" {
645+
fmt.Printf("v%s\nCommit: %s\nDate: %s\n", version, commit, date)
646+
} else {
647+
printModuleVersion()
648+
}
649+
}

Diff for: ‎mockgen/version.1.11.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"log"
2121
)
2222

23-
func printVersion() {
23+
func printModuleVersion() {
2424
log.Printf("No version information is available for Mockgen compiled with " +
2525
"version 1.11")
2626
}

Diff for: ‎mockgen/version.1.12.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"runtime/debug"
2424
)
2525

26-
func printVersion() {
26+
func printModuleVersion() {
2727
if bi, exists := debug.ReadBuildInfo(); exists {
2828
fmt.Println(bi.Main.Version)
2929
} else {

0 commit comments

Comments
 (0)
This repository has been archived.