mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-08 14:53:59 +00:00
Compare commits
14 Commits
046ce74cd9
...
35263f1dd6
Author | SHA1 | Date | |
---|---|---|---|
35263f1dd6 | |||
930e173a6a | |||
bea2a81afa | |||
53ed486b23 | |||
0b9c32a09d | |||
42d5617e3f | |||
e80ae9ab24 | |||
![]() |
86a6f7814b | ||
09034b5f9e | |||
f1ca2041c3 | |||
f5a29a2657 | |||
439f66eb87 | |||
415d0130ce | |||
abaa8e90b2 |
4
.github/workflows/golangci-lint.yml
vendored
4
.github/workflows/golangci-lint.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
with:
|
||||
go-version: stable
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v1.64
|
||||
version: v2.0.2
|
||||
args: --timeout=10m --config=.golangci.yml
|
||||
|
@ -1,16 +1,16 @@
|
||||
version: "2"
|
||||
|
||||
run:
|
||||
go: "1.24"
|
||||
concurrency: 8
|
||||
timeout: 10m
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
default: none
|
||||
enable:
|
||||
- asasalint
|
||||
- asciicheck
|
||||
- errcheck
|
||||
- gofmt
|
||||
- goimports
|
||||
- gomodguard
|
||||
- goprintffuncname
|
||||
- govet
|
||||
@ -21,7 +21,13 @@ linters:
|
||||
- prealloc
|
||||
- reassign
|
||||
- staticcheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- whitespace
|
||||
|
||||
settings:
|
||||
staticcheck:
|
||||
checks:
|
||||
- "all"
|
||||
- "-S1002"
|
||||
- "-ST1000"
|
||||
|
@ -18,6 +18,10 @@ vars:
|
||||
archs: [386, amd64, arm64]
|
||||
|
||||
tasks:
|
||||
run: go run main.go
|
||||
|
||||
fmt: gofmt -w -d .
|
||||
|
||||
lint: golangci-lint run
|
||||
|
||||
build: go build -ldflags "-s -w" -o "dodo"
|
||||
@ -26,15 +30,16 @@ tasks:
|
||||
silent: true
|
||||
cmds:
|
||||
- rm -rf binaries
|
||||
- for: { var: PLATFORMS, as: PLATFORM }
|
||||
cmd: |
|
||||
{{ $ext := "" }}
|
||||
- |
|
||||
{{ $ext := "" }}
|
||||
{{- range $platform := .PLATFORMS }}
|
||||
{{- if eq $platform.os "windows" }}
|
||||
{{ $ext = ".exe" }}
|
||||
{{- end }}
|
||||
|
||||
{{ if eq $.PLATFORM.os "windows" }}
|
||||
{{ $ext = ".exe" }}
|
||||
{{ end }}
|
||||
|
||||
{{range $arch := $.PLATFORM.archs}}
|
||||
echo "Building for {{$.PLATFORM.os}}/{{$arch}}"
|
||||
GOOS={{$.PLATFORM.os}} GOARCH={{$arch}} go build -ldflags "-s -w" -o "./binaries/dodo-{{$.PLATFORM.os}}-{{$arch}}{{$ext}}"
|
||||
{{end}}
|
||||
{{- range $arch := $platform.archs }}
|
||||
echo "Building for {{$platform.os}}/{{$arch}}"
|
||||
GOOS={{$platform.os}} GOARCH={{$arch}} go build -ldflags "-s -w" -o "./binaries/dodo-{{$platform.os}}-{{$arch}}{{$ext}}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- echo -e "\033[32m*** Build completed ***\033[0m"
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION string = "0.6.2"
|
||||
VERSION string = "0.6.3"
|
||||
DefaultUserAgent string = "Dodo/" + VERSION
|
||||
DefaultMethod string = "GET"
|
||||
DefaultTimeout time.Duration = time.Second * 10
|
||||
@ -145,20 +145,20 @@ func NewConfig() *Config {
|
||||
return &Config{}
|
||||
}
|
||||
|
||||
func (c *Config) Validate() []error {
|
||||
func (config *Config) Validate() []error {
|
||||
var errs []error
|
||||
if utils.IsNilOrZero(c.URL) {
|
||||
if utils.IsNilOrZero(config.URL) {
|
||||
errs = append(errs, errors.New("request URL is required"))
|
||||
} else {
|
||||
if c.URL.Scheme == "" {
|
||||
c.URL.Scheme = "http"
|
||||
if config.URL.Scheme == "" {
|
||||
config.URL.Scheme = "http"
|
||||
}
|
||||
if c.URL.Scheme != "http" && c.URL.Scheme != "https" {
|
||||
if config.URL.Scheme != "http" && config.URL.Scheme != "https" {
|
||||
errs = append(errs, errors.New("request URL scheme must be http or https"))
|
||||
}
|
||||
|
||||
urlParams := types.Params{}
|
||||
for key, values := range c.URL.Query() {
|
||||
for key, values := range config.URL.Query() {
|
||||
for _, value := range values {
|
||||
urlParams = append(urlParams, types.KeyValue[string, []string]{
|
||||
Key: key,
|
||||
@ -166,24 +166,24 @@ func (c *Config) Validate() []error {
|
||||
})
|
||||
}
|
||||
}
|
||||
c.Params = append(urlParams, c.Params...)
|
||||
c.URL.RawQuery = ""
|
||||
config.Params = append(urlParams, config.Params...)
|
||||
config.URL.RawQuery = ""
|
||||
}
|
||||
|
||||
if utils.IsNilOrZero(c.Method) {
|
||||
if utils.IsNilOrZero(config.Method) {
|
||||
errs = append(errs, errors.New("request method is required"))
|
||||
}
|
||||
if utils.IsNilOrZero(c.Timeout) {
|
||||
if utils.IsNilOrZero(config.Timeout) {
|
||||
errs = append(errs, errors.New("request timeout must be greater than 0"))
|
||||
}
|
||||
if utils.IsNilOrZero(c.DodosCount) {
|
||||
if utils.IsNilOrZero(config.DodosCount) {
|
||||
errs = append(errs, errors.New("dodos count must be greater than 0"))
|
||||
}
|
||||
if utils.IsNilOrZero(c.Duration) && utils.IsNilOrZero(c.RequestCount) {
|
||||
if utils.IsNilOrZero(config.Duration) && utils.IsNilOrZero(config.RequestCount) {
|
||||
errs = append(errs, errors.New("you should provide at least one of duration or request count"))
|
||||
}
|
||||
|
||||
for i, proxy := range c.Proxies {
|
||||
for i, proxy := range config.Proxies {
|
||||
if proxy.String() == "" {
|
||||
errs = append(errs, fmt.Errorf("proxies[%d]: proxy cannot be empty", i))
|
||||
} else if schema := proxy.Scheme; !slices.Contains(SupportedProxySchemes, schema) {
|
||||
|
@ -34,7 +34,7 @@ func (config *Config) ReadFile(filePath types.ConfigFile) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch config file from %s", filePath)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
data, err = io.ReadAll(io.Reader(resp.Body))
|
||||
if err != nil {
|
||||
@ -47,9 +47,10 @@ func (config *Config) ReadFile(filePath types.ConfigFile) error {
|
||||
}
|
||||
}
|
||||
|
||||
if fileExt == "json" {
|
||||
switch fileExt {
|
||||
case "json":
|
||||
return parseJSONConfig(data, config)
|
||||
} else if fileExt == "yml" || fileExt == "yaml" {
|
||||
case "yml", "yaml":
|
||||
return parseYAMLConfig(data, config)
|
||||
}
|
||||
}
|
||||
|
12
go.mod
12
go.mod
@ -4,18 +4,18 @@ go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.7
|
||||
github.com/valyala/fasthttp v1.59.0
|
||||
github.com/valyala/fasthttp v1.60.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
golang.org/x/net v0.36.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/term v0.30.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
)
|
||||
|
24
go.sum
24
go.sum
@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.7 h1:m+LbHpm0aIAPLzLbMfn8dc3Ht8MW7lsSO4MPItz/Uuo=
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.7/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@ -17,18 +17,18 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.59.0 h1:Qu0qYHfXvPk1mSLNqcFtEk6DpxgA26hy6bmydotDpRI=
|
||||
github.com/valyala/fasthttp v1.59.0/go.mod h1:GTxNb9Bc6r2a9D0TWNSPwDz78UxnTGBViY3xZNEqyYU=
|
||||
github.com/valyala/fasthttp v1.60.0 h1:kBRYS0lOhVJ6V+bYN8PqAHELKHtXqwq9zNMLKx1MBsw=
|
||||
github.com/valyala/fasthttp v1.60.0/go.mod h1:iY4kDgV3Gc6EqhRZ8icqcmlG6bqhcDXfuHgTO4FXCvc=
|
||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
|
||||
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
||||
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
5
main.go
5
main.go
@ -7,7 +7,6 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/aykhans/dodo/config"
|
||||
"github.com/aykhans/dodo/requests"
|
||||
@ -50,10 +49,6 @@ func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
go listenForTermination(func() { cancel() })
|
||||
|
||||
if requestConf.Duration > 0 {
|
||||
time.AfterFunc(requestConf.Duration, func() { cancel() })
|
||||
}
|
||||
|
||||
responses, err := requests.Run(ctx, requestConf)
|
||||
if err != nil {
|
||||
if err == types.ErrInterrupt {
|
||||
|
@ -72,11 +72,12 @@ func getClients(
|
||||
func getDialFunc(proxy *url.URL, timeout time.Duration) (fasthttp.DialFunc, error) {
|
||||
var dialer fasthttp.DialFunc
|
||||
|
||||
if proxy.Scheme == "socks5" || proxy.Scheme == "socks5h" {
|
||||
switch proxy.Scheme {
|
||||
case "socks5", "socks5h":
|
||||
dialer = fasthttpproxy.FasthttpSocksDialerDualStack(proxy.String())
|
||||
} else if proxy.Scheme == "http" {
|
||||
case "http":
|
||||
dialer = fasthttpproxy.FasthttpHTTPDialerDualStackTimeout(proxy.String(), timeout)
|
||||
} else {
|
||||
default:
|
||||
return nil, errors.New("unsupported proxy scheme")
|
||||
}
|
||||
return dialer, nil
|
||||
|
@ -20,6 +20,9 @@ import (
|
||||
// - ctx: The context for managing request lifecycle and cancellation.
|
||||
// - requestConfig: The configuration for the request, including timeout, proxies, and other settings.
|
||||
func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
clients := getClients(
|
||||
ctx,
|
||||
requestConfig.Timeout,
|
||||
@ -31,6 +34,10 @@ func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, e
|
||||
return nil, types.ErrInterrupt
|
||||
}
|
||||
|
||||
if requestConfig.Duration > 0 {
|
||||
time.AfterFunc(requestConfig.Duration, func() { cancel() })
|
||||
}
|
||||
|
||||
responses := releaseDodos(ctx, requestConfig, clients)
|
||||
if ctx.Err() != nil && len(responses) == 0 {
|
||||
return nil, types.ErrInterrupt
|
||||
@ -58,9 +65,9 @@ func releaseDodos(
|
||||
wg sync.WaitGroup
|
||||
streamWG sync.WaitGroup
|
||||
requestCountPerDodo uint
|
||||
dodosCount uint = requestConfig.GetValidDodosCountForRequests()
|
||||
responses = make([][]*Response, dodosCount)
|
||||
increase = make(chan int64, requestConfig.RequestCount)
|
||||
dodosCount = requestConfig.GetValidDodosCountForRequests()
|
||||
responses = make([][]*Response, dodosCount)
|
||||
increase = make(chan int64, requestConfig.RequestCount)
|
||||
)
|
||||
|
||||
wg.Add(int(dodosCount))
|
||||
|
@ -13,12 +13,12 @@ type Body []string
|
||||
func (body Body) String() string {
|
||||
var buffer bytes.Buffer
|
||||
if len(body) == 0 {
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
if len(body) == 1 {
|
||||
buffer.WriteString(body[0])
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
buffer.WriteString(text.FgBlue.Sprint("Random") + "[\n")
|
||||
@ -41,7 +41,7 @@ func (body Body) String() string {
|
||||
}
|
||||
|
||||
buffer.WriteString("\n]")
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (body *Body) UnmarshalJSON(b []byte) error {
|
||||
|
@ -14,7 +14,7 @@ type Cookies []KeyValue[string, []string]
|
||||
func (cookies Cookies) String() string {
|
||||
var buffer bytes.Buffer
|
||||
if len(cookies) == 0 {
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
indent := " "
|
||||
@ -53,7 +53,7 @@ func (cookies Cookies) String() string {
|
||||
buffer.WriteString(",\n" + text.FgGreen.Sprintf("+%d cookies", remainingPairs))
|
||||
}
|
||||
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (cookies *Cookies) AppendByKey(key, value string) {
|
||||
|
@ -32,7 +32,7 @@ func (duration *Duration) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
func (duration Duration) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(duration.Duration.String())
|
||||
return json.Marshal(duration.String())
|
||||
}
|
||||
|
||||
func (duration *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
|
@ -14,7 +14,7 @@ type Headers []KeyValue[string, []string]
|
||||
func (headers Headers) String() string {
|
||||
var buffer bytes.Buffer
|
||||
if len(headers) == 0 {
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
indent := " "
|
||||
@ -53,7 +53,7 @@ func (headers Headers) String() string {
|
||||
buffer.WriteString(",\n" + text.FgGreen.Sprintf("+%d headers", remainingPairs))
|
||||
}
|
||||
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (headers *Headers) AppendByKey(key, value string) {
|
||||
|
@ -14,7 +14,7 @@ type Params []KeyValue[string, []string]
|
||||
func (params Params) String() string {
|
||||
var buffer bytes.Buffer
|
||||
if len(params) == 0 {
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
indent := " "
|
||||
@ -53,7 +53,7 @@ func (params Params) String() string {
|
||||
buffer.WriteString(",\n" + text.FgGreen.Sprintf("+%d params", remainingPairs))
|
||||
}
|
||||
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (params *Params) AppendByKey(key, value string) {
|
||||
|
@ -14,12 +14,12 @@ type Proxies []url.URL
|
||||
func (proxies Proxies) String() string {
|
||||
var buffer bytes.Buffer
|
||||
if len(proxies) == 0 {
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
if len(proxies) == 1 {
|
||||
buffer.WriteString(proxies[0].String())
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
buffer.WriteString(text.FgBlue.Sprint("Random") + "[\n")
|
||||
@ -42,7 +42,7 @@ func (proxies Proxies) String() string {
|
||||
}
|
||||
|
||||
buffer.WriteString("\n]")
|
||||
return string(buffer.Bytes())
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
func (proxies *Proxies) UnmarshalJSON(b []byte) error {
|
||||
|
@ -18,7 +18,7 @@ func (requestURL *RequestURL) UnmarshalJSON(data []byte) error {
|
||||
|
||||
parsedURL, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return errors.New("Request URL is invalid")
|
||||
return errors.New("request URL is invalid")
|
||||
}
|
||||
|
||||
requestURL.URL = *parsedURL
|
||||
@ -33,7 +33,7 @@ func (requestURL *RequestURL) UnmarshalYAML(unmarshal func(interface{}) error) e
|
||||
|
||||
parsedURL, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return errors.New("Request URL is invalid")
|
||||
return errors.New("request URL is invalid")
|
||||
}
|
||||
|
||||
requestURL.URL = *parsedURL
|
||||
|
@ -32,7 +32,7 @@ func (timeout *Timeout) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
func (timeout Timeout) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(timeout.Duration.String())
|
||||
return json.Marshal(timeout.String())
|
||||
}
|
||||
|
||||
func (timeout *Timeout) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
|
@ -6,9 +6,5 @@ func IsNilOrZero[T comparable](value *T) bool {
|
||||
}
|
||||
|
||||
var zero T
|
||||
if *value == zero {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return *value == zero
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ func Flatten[T any](nested [][]*T) []*T {
|
||||
// The returned function isn't thread-safe and should be used in a single-threaded context.
|
||||
func RandomValueCycle[Value any](values []Value, localRand *rand.Rand) func() Value {
|
||||
var (
|
||||
clientsCount int = len(values)
|
||||
currentIndex int = localRand.Intn(clientsCount)
|
||||
stopIndex int = currentIndex
|
||||
clientsCount = len(values)
|
||||
currentIndex = localRand.Intn(clientsCount)
|
||||
stopIndex = currentIndex
|
||||
)
|
||||
|
||||
return func() Value {
|
||||
|
Loading…
x
Reference in New Issue
Block a user