Skip to content

Commit 3020f69

Browse files
authored
Add .goreleaser.yml and version (#61)
1 parent f0a8e3c commit 3020f69

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

.goreleaser.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
project_name: wzprof
2+
dist: ./goreleaser/dist
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
8+
builds:
9+
- main: ./cmd/wzprof/main.go
10+
binary: wzprof
11+
mod_timestamp: '{{ .CommitTimestamp }}'
12+
13+
ldflags:
14+
- -X main.version={{.Version}}
15+
16+
release:
17+
github:
18+
owner: stealthrocket
19+
name: wzprof

cmd/wzprof/main.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,19 @@ func silenceContextCanceled(err error) error {
175175
}
176176

177177
var (
178-
pprofAddr string
179-
cpuProfile string
180-
memProfile string
181-
sampleRate float64
182-
hostProfile bool
183-
hostTime bool
184-
inuseMemory bool
185-
mounts string
178+
pprofAddr string
179+
cpuProfile string
180+
memProfile string
181+
sampleRate float64
182+
hostProfile bool
183+
hostTime bool
184+
inuseMemory bool
185+
mounts string
186+
printVersion bool
186187
)
187188

189+
var version = "dev"
190+
188191
func init() {
189192
log.Default().SetOutput(os.Stderr)
190193
flag.StringVar(&pprofAddr, "pprof-addr", "", "Address where to expose a pprof HTTP endpoint.")
@@ -195,11 +198,17 @@ func init() {
195198
flag.BoolVar(&hostTime, "iowait", false, "Include time spent waiting on I/O in guest CPU profile.")
196199
flag.BoolVar(&inuseMemory, "inuse", false, "Include snapshots of memory in use (experimental).")
197200
flag.StringVar(&mounts, "mount", "", "Comma-separated list of directories to mount (e.g. /tmp:/tmp:ro).")
201+
flag.BoolVar(&printVersion, "version", false, "Print the wzprof version.")
198202
}
199203

200204
func run(ctx context.Context) error {
201205
flag.Parse()
202206

207+
if printVersion {
208+
fmt.Printf("wzprof version %s\n", version)
209+
return nil
210+
}
211+
203212
args := flag.Args()
204213
if len(args) != 1 {
205214
// TODO: print flag usage

0 commit comments

Comments
 (0)