intial commit
This commit is contained in:
parent
c47cc6699a
commit
63006015a6
57
main.go
Normal file
57
main.go
Normal file
@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
type WeatherAPI struct {
|
||||
Coord Coord `json:"coord"`
|
||||
Weather Weather `json:"weather`
|
||||
Base string `json:"base"`
|
||||
Main Main `json:"main"`
|
||||
Visability string `json:"visibility"`
|
||||
Wind Wind `json:"wind"`
|
||||
Rain Rain `json:"rain"`
|
||||
Clouds Cloud `json:"cloud"`
|
||||
dt DT `json:"dt"`
|
||||
Sys Sys `json:"sys"`
|
||||
TimeZone int `json:"timezone"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
COD int `json:"cod"`
|
||||
}
|
||||
|
||||
type Coord struct {
|
||||
//etc
|
||||
}
|
||||
|
||||
func main() {
|
||||
/*
|
||||
//setting up openweathermap api
|
||||
lat := "56.122970"
|
||||
lon := "-3.932390"
|
||||
city := "Stirling, uk"
|
||||
api_key := "29e5139b86638988d333a28ba360bfd9"
|
||||
full := "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=" + api_key + ""
|
||||
fmt.Printf("\n------\nWeather url: %+s\n---------\n", full)
|
||||
|
||||
//read webpage
|
||||
url := full
|
||||
resp, err := http.Get(url)
|
||||
//reads html as a slice of bytes
|
||||
html, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
*/
|
||||
//print the html
|
||||
//fmt.Printf("%s\n", html)
|
||||
/*
|
||||
out, _ := json.Marshal(html)
|
||||
fmt.Printf("%s\n", out)
|
||||
*/
|
||||
/*
|
||||
byteArray, error := json.MarshalIndent(html, "", " ")
|
||||
if error != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(string(byteArray))
|
||||
*/
|
||||
}
|
47
stirling.json
Normal file
47
stirling.json
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"coord": {
|
||||
"lon": -3.9324,
|
||||
"lat": 56.123
|
||||
},
|
||||
"weather": [
|
||||
{
|
||||
"id": 502,
|
||||
"main": "Rain",
|
||||
"description": "heavy intensity rain",
|
||||
"icon": "10d"
|
||||
}
|
||||
],
|
||||
"base": "stations",
|
||||
"main": {
|
||||
"temp": 279.55,
|
||||
"feels_like": 277.93,
|
||||
"temp_min": 278.39,
|
||||
"temp_max": 280.56,
|
||||
"pressure": 991,
|
||||
"humidity": 95
|
||||
},
|
||||
"visibility": 4047,
|
||||
"wind": {
|
||||
"speed": 2.24,
|
||||
"deg": 88,
|
||||
"gust": 4.02
|
||||
},
|
||||
"rain": {
|
||||
"1h": 4.86
|
||||
},
|
||||
"clouds": {
|
||||
"all": 100
|
||||
},
|
||||
"dt": 1644753046,
|
||||
"sys": {
|
||||
"type": 2,
|
||||
"id": 2009014,
|
||||
"country": "GB",
|
||||
"sunrise": 1644738387,
|
||||
"sunset": 1644772418
|
||||
},
|
||||
"timezone": 0,
|
||||
"id": 2636910,
|
||||
"name": "Stirling",
|
||||
"cod": 200
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user