Compare commits

..

6 Commits

Author SHA1 Message Date
a468f663bf 🔖 Bump version to 0.5.2 2024-11-23 16:29:06 +04:00
d98fb477d4 🔨 Update usage text 2024-11-23 16:28:19 +04:00
bf169d3eb1 🔨 Remove debug print 2024-11-23 16:27:46 +04:00
0335b5cf6e 📚 Update docs 2024-11-23 16:18:21 +04:00
9c5d7bf135 📚 Update docs 2024-11-23 16:13:38 +04:00
ede74c17b2 📚 Add docs 2024-11-23 16:13:17 +04:00
5 changed files with 14 additions and 10 deletions

View File

@ -33,7 +33,7 @@ Follow the steps below to build dodo:
3. **Build the project:** 3. **Build the project:**
```sh ```sh
go build -o dodo go build -ldflags "-s -w" -o dodo
``` ```
This will generate an executable named `dodo` in the project directory. This will generate an executable named `dodo` in the project directory.
@ -58,8 +58,9 @@ You can find an example config structure in the [config.json](https://github.com
{ {
"method": "GET", "method": "GET",
"url": "https://example.com", "url": "https://example.com",
"timeout": 10000, "no_proxy_check": false,
"dodos_count": 50, "timeout": 2000,
"dodos_count": 10,
"request_count": 1000, "request_count": 1000,
"params": {}, "params": {},
"headers": {}, "headers": {},
@ -77,7 +78,7 @@ You can find an example config structure in the [config.json](https://github.com
] ]
} }
``` ```
Send 1000 GET requests to https://example.com with 5 parallel dodos (threads) and a timeout of 10000 milliseconds: Send 1000 GET requests to https://example.com with 10 parallel dodos (threads) and a timeout of 2000 milliseconds:
```sh ```sh
dodo -c /path/config.json dodo -c /path/config.json

View File

@ -11,7 +11,7 @@ import (
) )
const ( const (
VERSION string = "0.5.1" VERSION string = "0.5.2"
DefaultUserAgent string = "Dodo/" + VERSION DefaultUserAgent string = "Dodo/" + VERSION
ProxyCheckURL string = "https://www.google.com" ProxyCheckURL string = "https://www.google.com"
DefaultMethod string = "GET" DefaultMethod string = "GET"

View File

@ -31,7 +31,7 @@ func CLIConfigReader() (*config.CLIConfig, error) {
dodo -c /path/to/config/file/config.json dodo -c /path/to/config/file/config.json
Usage with all flags: Usage with all flags:
dodo -c /path/to/config/file/config.json -u https://example.com -m POST -d 10 -r 1000 -t 2000`, dodo -c /path/to/config/file/config.json -u https://example.com -m POST -d 10 -r 1000 -t 2000 --no-proxy-check -y`,
Run: func(cmd *cobra.Command, args []string) {}, Run: func(cmd *cobra.Command, args []string) {},
SilenceErrors: true, SilenceErrors: true,
SilenceUsage: true, SilenceUsage: true,

View File

@ -2,7 +2,6 @@ package requests
import ( import (
"context" "context"
"fmt"
"sync" "sync"
"time" "time"
@ -25,8 +24,6 @@ import (
// - Responses: A collection of responses from the executed requests. // - Responses: A collection of responses from the executed requests.
// - error: An error if the operation fails, such as no internet connection or an interrupt. // - error: An error if the operation fails, such as no internet connection or an interrupt.
func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) { func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error) {
fmt.Println("No Proxy Check:", requestConfig.NoProxyCheck)
checkConnectionCtx, checkConnectionCtxCancel := context.WithTimeout(ctx, 8*time.Second) checkConnectionCtx, checkConnectionCtxCancel := context.WithTimeout(ctx, 8*time.Second)
if !checkConnection(checkConnectionCtx) { if !checkConnection(checkConnectionCtx) {
checkConnectionCtxCancel() checkConnectionCtxCancel()

View File

@ -5,15 +5,19 @@ import (
"errors" "errors"
) )
// Don't call this struct directly, use NewOption[T] or NewNoneOption[T] instead.
type Option[T any] struct { type Option[T any] struct {
// value holds the actual value of the Option if it is not None.
value T value T
none bool // none indicates whether the Option is None (i.e., has no value).
none bool
} }
func (o *Option[T]) IsNone() bool { func (o *Option[T]) IsNone() bool {
return o.none return o.none
} }
// The returned value can be nil, if the Option is None, it will return nil and an error.
func (o *Option[T]) ValueOrErr() (*T, error) { func (o *Option[T]) ValueOrErr() (*T, error) {
if o.IsNone() { if o.IsNone() {
return nil, errors.New("Option is None") return nil, errors.New("Option is None")
@ -21,6 +25,7 @@ func (o *Option[T]) ValueOrErr() (*T, error) {
return &o.value, nil return &o.value, nil
} }
// The returned value can't be nil, if the Option is None, it will return the default value.
func (o *Option[T]) ValueOr(def *T) *T { func (o *Option[T]) ValueOr(def *T) *T {
if o.IsNone() { if o.IsNone() {
return def return def
@ -28,6 +33,7 @@ func (o *Option[T]) ValueOr(def *T) *T {
return &o.value return &o.value
} }
// The returned value can't be nil, if the Option is None, it will panic.
func (o *Option[T]) ValueOrPanic() *T { func (o *Option[T]) ValueOrPanic() *T {
if o.IsNone() { if o.IsNone() {
panic("Option is None") panic("Option is None")