mirror of
https://github.com/google/gops.git
synced 2024-11-24 08:22:25 +02:00
rename exit to exitIfError
This commit is contained in:
parent
b73016d838
commit
c4c8158bfa
17
gops.go
17
gops.go
@ -57,21 +57,21 @@ func main() {
|
||||
}
|
||||
if *stack {
|
||||
out, err := cmd(signal.Stack)
|
||||
exit(err)
|
||||
exitIfError(err)
|
||||
fmt.Println(out)
|
||||
}
|
||||
if *gc {
|
||||
_, err := cmd(signal.GC)
|
||||
exit(err)
|
||||
exitIfError(err)
|
||||
}
|
||||
if *memstats {
|
||||
out, err := cmd(signal.MemStats)
|
||||
exit(err)
|
||||
exitIfError(err)
|
||||
fmt.Printf(out)
|
||||
}
|
||||
if *version {
|
||||
out, err := cmd(signal.Version)
|
||||
exit(err)
|
||||
exitIfError(err)
|
||||
fmt.Printf(out)
|
||||
}
|
||||
}
|
||||
@ -145,9 +145,10 @@ func usage() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func exit(err error) {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
func exitIfError(err error) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user