-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (36 loc) · 799 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"io/ioutil"
"net/http"
"sync"
"gopkg.in/yaml.v2"
)
type TestConfig struct {
Hostname string
Tests map[string]int
}
func main() {
var config TestConfig
var wg sync.WaitGroup
source, err := ioutil.ReadFile("tests.yml")
if err != nil {
panic(err)
}
err = yaml.Unmarshal(source, &config)
if err != nil {
panic(err)
}
// avoid lookup
prefix := config.Hostname
fmt.Printf("Begin status checking of: %v\n\n", prefix)
wg.Add(len(config.Tests))
for path, status_code := range config.Tests {
go func(prefix, path string, status_code int) {
defer wg.Done()
resp, _ := http.Get(prefix + path)
fmt.Printf("Checked path: %v\nValue: %v\nExpectation: %v\n\n", path, resp.StatusCode, status_code)
}(prefix, path, status_code)
}
wg.Wait()
}