From 6f4bb496f84a742c857df59cb55083bd3c15a05d Mon Sep 17 00:00:00 2001 From: Sergey Dryabzhinsky Date: Thu, 10 Aug 2023 08:45:19 +0300 Subject: [PATCH 1/2] Add commandline option to output version of GB/golang, + change GB version to 0.2.0 --- config.go | 7 +++++++ main.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index ebea58b..e21ab50 100644 --- a/config.go +++ b/config.go @@ -60,6 +60,8 @@ func LoadConfig() (config *Config, err error) { showHelp := flag.Bool("h", false, "Display usage information (this message)") + showVersion := flag.Bool("V", false, "Display version information (and exit)") + flag.Usage = func() { fmt.Print("Usage: gb [options] http[s]://hostname[:port]/path\nOptions are:\n") flag.PrintDefaults() @@ -72,6 +74,11 @@ func LoadConfig() (config *Config, err error) { os.Exit(0) } + if *showVersion { + fmt.Print("GoHttpBench:" + GBVersion + "; GoLang: " + runtime.Version() + "\n") + os.Exit(0) + } + if flag.NArg() != 1 { flag.Usage() os.Exit(-1) diff --git a/main.go b/main.go index 69b2a9a..24db56d 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( ) const ( - GBVersion = "0.1.9" + GBVersion = "0.2.0" MaxExecutionTimeout = time.Duration(30) * time.Second MaxRequests = 50000 // for timelimit ) From 3c477a025e0585995a6784616cb89fc26b6dbe1b Mon Sep 17 00:00:00 2001 From: Sergey Dryabzhinsky Date: Thu, 10 Aug 2023 08:50:08 +0300 Subject: [PATCH 2/2] Update version output, update readme --- README.md | 13 +++++++++++++ config.go | 2 +- main.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6120e05..24ff7e4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ go get github.com/parkghost/gohttpbench go build -o gb github.com/parkghost/gohttpbench ``` +or + +``` +git clone github.com/parkghost/gohttpbench +GO111MODULE=off go build -ldflags "-s" -o gb +``` + Usage ----------- @@ -27,6 +34,7 @@ Options are: -T="text/plain": Content-type header for POSTing, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' -c=1: Number of multiple requests to make -h=false: Display usage information (this message) + -V=false: Display version information (and exit) -i=false: Use HEAD instead of GET -k=false: Use HTTP KeepAlive feature -n=1: Number of requests to perform @@ -91,6 +99,11 @@ Options are: 99% 14 100% 32 (longest request) +Version output: +``` +./gb -V +GoHttpBench: 0.2.0-dev; GoLang: go1.21.0 +``` Author ------- diff --git a/config.go b/config.go index e21ab50..35175b0 100644 --- a/config.go +++ b/config.go @@ -75,7 +75,7 @@ func LoadConfig() (config *Config, err error) { } if *showVersion { - fmt.Print("GoHttpBench:" + GBVersion + "; GoLang: " + runtime.Version() + "\n") + fmt.Print("GoHttpBench: " + GBVersion + "; GoLang: " + runtime.Version() + "\n") os.Exit(0) } diff --git a/main.go b/main.go index 24db56d..a7deebf 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( ) const ( - GBVersion = "0.2.0" + GBVersion = "0.2.0-dev" MaxExecutionTimeout = time.Duration(30) * time.Second MaxRequests = 50000 // for timelimit )