+
Skip to content

Flags #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,42 @@ Minimalistic performance and load testing tool written in Go.
- Download and install to MacOS

```
curl -L https://github.com/vitalyliber/gostorm/releases/download/v.1.0.1/gostorm_macos -o /usr/local/bin/gostorm
curl -L https://github.com/vitalyliber/gostorm/releases/download/v.1.0.2/gostorm_macos -o /usr/local/bin/gostorm
sudo chmod a+x /usr/local/bin/gostorm
```

- Download and install to Linux


```
curl -L https://github.com/vitalyliber/gostorm/releases/download/v.1.0.1/gostorm_linux -o /usr/local/bin/gostorm
```bash
curl -L https://github.com/vitalyliber/gostorm/releases/download/v.1.0.2/gostorm_linux -o /usr/local/bin/gostorm
sudo chmod a+x /usr/local/bin/gostorm
```

- Run and paste url:
- Run with flags:
```bash
Enter site url: https://example.com
gostorm -url=https://some-url.ru -streams=500 -timeout=1
```
- Enter number of streams:

- Check the site accessible

## Flags

```bash
Enter number of streams: 500
gostorm -h
```

- Check the site accessible
Output:
```bash
Usage of ./main:
-streams int
a number of streams (default 42)
-timeout int
timeout in minutes for working of program (default 1)
-url string
a site url (default "https://some-url.com")

```

## Build for your platform

Expand Down
31 changes: 12 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
package main

import (
"fmt"
"net/http"
"bufio"
"flag"
"log"
"os"
"strconv"
"strings"
"net/http"
"time"
)

var counter = 0
var urlString = flag.String("url", "https://some-url.com", "a site url")
var streams = flag.Int("streams", 42, "a number of streams")
var timeout = flag.Int("timeout", 1, "timeout in minutes for working of program")

func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter site url: ")
urlString, _ := reader.ReadString('\n')
urlString = strings.TrimSuffix(urlString, "\n")

fmt.Print("Enter number of streams: ")
streamsString, _ := reader.ReadString('\n')
streamsString = strings.TrimSuffix(streamsString, "\n")
streams, _ := strconv.Atoi(streamsString)
log.Println("Streams:", streams)
flag.Parse()
log.Println("Url:", *urlString)
log.Println("Streams number:", *streams)

sum := 1
for sum < streams {
go storm(urlString)
for sum < *streams {
go storm(*urlString)
log.Println("Goroutine was created with number:", sum)
sum += 1
}

storm(urlString)
time.Sleep(time.Duration(*timeout) * time.Minute)
}

func storm(url string) {
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载