Skip to content

Commit 3551884

Browse files
committed
add host connectivity status to debug output
possible helps with issue #159
1 parent 30a1918 commit 3551884

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

cmd/debug.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55
"log"
6+
"net/http"
67
"os"
78
"runtime"
89

@@ -45,6 +46,17 @@ func Debug(ctx *cli.Context) {
4546
fmt.Println("Config file: <not configured>")
4647
fmt.Println("API Key: <not configured>")
4748
}
48-
fmt.Printf("API: %s\n", c.API)
49+
fmt.Printf("API: %s [%s]\n", c.API, pingUrl(c.API))
50+
fmt.Printf("XAPI: %s [%s]\n", c.XAPI, pingUrl(c.XAPI))
4951
fmt.Printf("Exercises Directory: %s\n", c.Dir)
5052
}
53+
54+
func pingUrl(url string) string {
55+
res, err := http.Get(url)
56+
if err != nil {
57+
return err.Error()
58+
}
59+
defer res.Body.Close()
60+
61+
return "connected"
62+
}

0 commit comments

Comments
 (0)