diff --git a/README.md b/README.md index f03aaae..1016726 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The `-c` flag allows to give a country code. Else `ch` will be used. ## Background -The program uses `https://api.mullvad.net/www/relays//` to get the current server list, pings the ones with the right country and outputs the server with the lowest ping. ## Integration into a script diff --git a/main.go b/main.go index 2e94a15..d6bdb41 100644 --- a/main.go +++ b/main.go @@ -40,7 +40,7 @@ func main() { } else { serverJson, err := json.Marshal(best) if err != nil { - log.Fatal().Err(err) + log.Fatal().Err(err).Msg("Couldn't marshal server information to Json") } fmt.Println(string(serverJson)) } @@ -66,7 +66,7 @@ func selectBestServerIndex(servers []server, country string) int { func getServers(serverType string) []server { resp, err := http.Get("https://api.mullvad.net/www/relays/" + serverType + "/") if err != nil { - log.Fatal().Err(err) + log.Fatal().Err(err).Msg("Couldn't retrieve servers") } responseBody, err := ioutil.ReadAll(resp.Body) defer func(Body io.ReadCloser) { @@ -81,7 +81,7 @@ func getServers(serverType string) []server { var servers []server err = json.Unmarshal(responseBody, &servers) if err != nil { - log.Fatal().Err(err) + log.Fatal().Err(err).Msg("couldn't unmarshall server json") } return servers }