Skip to content

Commit 7b9e24c

Browse files
cmd: print version
1 parent 2afb038 commit 7b9e24c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

exec/http/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"crypto/hmac"
55
"crypto/sha256"
66
"encoding/hex"
7+
"fmt"
78
"github.com/BurntSushi/toml"
89
"github.com/gin-gonic/gin"
910
"github.com/gin-gonic/gin/binding"
@@ -27,6 +28,11 @@ var (
2728
)
2829

2930
func init() {
31+
if len(os.Args) > 1 && os.Args[1] == "--version" {
32+
fmt.Println(fullVersion)
33+
os.Exit(0)
34+
}
35+
3036
log.Printf("network-measure HTTP %s, built at %s\n", fullVersion, buildDate)
3137
config.SetDefault()
3238

exec/ws/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ func handleTLS(body []byte) (r []byte) {
212212
}
213213

214214
func init() {
215+
if len(os.Args) > 1 && os.Args[1] == "--version" {
216+
fmt.Println(fullVersion)
217+
os.Exit(0)
218+
}
219+
215220
log.Printf("network-measure Websocket %s, built at %s\n", fullVersion, buildDate)
216221

217222
config.SetDefault()
@@ -386,7 +391,9 @@ func main() {
386391
}
387392

388393
CleanUp:
389-
close(stopper)
394+
if stopper != nil {
395+
close(stopper)
396+
}
390397
if conn != nil {
391398
_ = conn.Close()
392399
}

0 commit comments

Comments
 (0)