|
|
|
@ -16,6 +16,9 @@ func main() { |
|
|
|
|
flag.StringVar(&apiKey, "api", "none", "Enter you api key here") |
|
|
|
|
flag.Parse() |
|
|
|
|
|
|
|
|
|
var filename string |
|
|
|
|
filename = "weather.json" |
|
|
|
|
|
|
|
|
|
full := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "," + code + "&units=metric" + "&appid=" + apiKey + "" |
|
|
|
|
|
|
|
|
|
//read webpage
|
|
|
|
@ -27,7 +30,8 @@ func main() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Create file
|
|
|
|
|
createFile(string(html)) |
|
|
|
|
createFile(string(html), filename) |
|
|
|
|
defer removeFile(filename) //delete file at the end
|
|
|
|
|
|
|
|
|
|
//Load the file
|
|
|
|
|
data, err := loadJSON("weather.json") |
|
|
|
@ -38,7 +42,4 @@ func main() { |
|
|
|
|
|
|
|
|
|
//Print the weather!
|
|
|
|
|
printWeather(data) |
|
|
|
|
|
|
|
|
|
//remove the file at the end
|
|
|
|
|
removeFile("weather.json") |
|
|
|
|
} |
|
|
|
|