package weather import ( "fmt" "io" "net/http" "time" ) func Get(city string) (string, error) { client := http.Client{ Timeout: 30 * time.Second, } u := fmt.Sprintf(`https://wttr.in/%s?format=%%l:+%%t+(ощущается+как+%%f)+%%c+%%C`, city) req, _ := http.NewRequest(http.MethodGet, u, nil) req.Header.Set("Accept-Language", "ru") resp, err := client.Do(req) if err != nil { return "", err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return "", fmt.Errorf("Не смог получить погоду") } result, err := io.ReadAll(resp.Body) if err != nil { return "", err } return string(result), nil }