Line | |
---|
1 | package main
|
---|
2 |
|
---|
3 | import (
|
---|
4 | "fmt"
|
---|
5 | "io"
|
---|
6 | "net/http"
|
---|
7 | )
|
---|
8 |
|
---|
9 | // Prints the current forecast for a region in standard output
|
---|
10 | // Required arguments: region
|
---|
11 | // Optional arguments: format
|
---|
12 | func ShowForecast(region string, format string, lang string) {
|
---|
13 | query := "https://wttr.in/" + region + "?" + format + "&lang" + lang
|
---|
14 | resp, err := http.Get(query)
|
---|
15 | sanityCheck(err)
|
---|
16 | defer resp.Body.Close()
|
---|
17 | body, err := io.ReadAll(resp.Body)
|
---|
18 | sanityCheck(err)
|
---|
19 | fmt.Printf("%s", body)
|
---|
20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.