Skip to content

Commit

Permalink
Use github.com/spf13/pflag
Browse files Browse the repository at this point in the history
  • Loading branch information
GitRowin committed Jun 24, 2024
1 parent 5b6f41f commit 3edfd93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ module httping
go 1.21

require github.com/montanaflynn/stats v0.7.1

require github.com/spf13/pflag v1.0.5
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"crypto/tls"
"errors"
"flag"
"fmt"
"github.com/montanaflynn/stats"
flag "github.com/spf13/pflag"
"io"
"net/http"
"net/http/httptrace"
Expand All @@ -30,9 +30,9 @@ var (
)

func init() {
flag.UintVar(&count, "count", 0, "Number of requests to send")
flag.UintVar(&delay, "delay", 1000, "Minimum delay between requests in milliseconds")
flag.UintVar(&timeout, "timeout", 5000, "Request timeout in milliseconds")
flag.UintVarP(&count, "count", "n", 0, "Number of requests to send")
flag.UintVarP(&delay, "delay", "d", 1000, "Minimum delay between requests in milliseconds")
flag.UintVarP(&timeout, "timeout", "t", 5000, "Request timeout in milliseconds")
flag.BoolVar(&enableKeepAlive, "enable-keep-alive", false, "Whether to use keep-alive")
flag.BoolVar(&disableCompression, "disable-compression", false, "Whether to disable compression")
flag.BoolVar(&disableHttp2, "disable-h2", false, "Whether to disable HTTP/2")
Expand All @@ -57,6 +57,7 @@ type Statistics struct {
}

func main() {
flag.CommandLine.SortFlags = false
flag.Parse()

targetUrl = flag.Arg(0)
Expand Down

0 comments on commit 3edfd93

Please sign in to comment.