2016-06-07 06:19:48 +02:00
|
|
|
// Fetch prints the content found at a URL.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-01-12 11:29:02 +01:00
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"time"
|
2016-06-07 06:19:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-01-12 11:29:02 +01:00
|
|
|
time.Sleep(60 * time.Second)
|
|
|
|
for _, url := range os.Args[1:] {
|
|
|
|
resp, err := http.Get(url)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "fetch: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
b, err := ioutil.ReadAll(resp.Body)
|
|
|
|
resp.Body.Close()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "fetch: reading %s: %v\n", url, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
// fmt.Printf("%s", b)
|
2016-06-07 06:19:48 +02:00
|
|
|
|
2017-01-12 11:29:02 +01:00
|
|
|
if strings.Contains(string(b), "Harbor") {
|
|
|
|
fmt.Printf("sucess!\n")
|
|
|
|
} else {
|
|
|
|
fmt.Println("the response does not contain \"Harbor\"!")
|
|
|
|
|
|
|
|
fmt.Println(string(b))
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2016-06-07 06:19:48 +02:00
|
|
|
|
2017-01-12 11:29:02 +01:00
|
|
|
}
|
|
|
|
}
|