master
Simon Kellet 3 years ago
parent 14f7396e22
commit e814e7b9ea
  1. 15
      README.md
  2. BIN
      go-weather
  3. 7
      main.go

@ -9,21 +9,20 @@ You will need a OpenWeather API-Key. This can be done by opening a free account
./go-weather -h ./go-weather -h
``` ```
Will give: Will give:
``` ```text
Usage of go-weather: Usage of ./go-weather:
-api string -api string
Enter Code e.g. uk, us etc... Default(none) (default "none") Enter you api key here (default "none")
-city string -city string
Enter city e.g. London, Glasgow etc... (Default: London) (default "London") Enter city e.g. London (default "London")
-code string -code string
Enter Code e.g. uk, us etc... (Default: uk) (default "uk") Enter Code e.g. uk (default "uk")
``` ```
Running the command in a terminal like so:
``` ```
./go-weather -api=API-KEY -city=Glasgow -code=uk ./go-weather -api=API-KEY -city=Glasgow -code=uk
``` ```
Will give: **Will give:**
``` ```
02/17/2022 17:03 02/17/2022 17:03
📍Location: Glasgow, GB 📍Location: Glasgow, GB

Binary file not shown.

@ -76,9 +76,9 @@ type Sys struct {
func main() { func main() {
//set up the flags for the program to use! //set up the flags for the program to use!
var city, code, api_key string var city, code, api_key string
flag.StringVar(&city, "city", "London", "Enter city e.g. London, Glasgow etc... (Default: London)") flag.StringVar(&city, "city", "London", "Enter city e.g. London")
flag.StringVar(&code, "code", "uk", "Enter Code e.g. uk, us etc... (Default: uk)") flag.StringVar(&code, "code", "uk", "Enter Code e.g. uk")
flag.StringVar(&api_key, "api", "none", "Enter you api key here... (Default: none") flag.StringVar(&api_key, "api", "none", "Enter you api key here")
flag.Parse() flag.Parse()
full := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "," + code + "&units=metric" + "&appid=" + api_key + "" full := "https://api.openweathermap.org/data/2.5/weather?q=" + city + "," + code + "&units=metric" + "&appid=" + api_key + ""
@ -88,7 +88,6 @@ func main() {
//Create file //Create file
createFile(string(html), false) createFile(string(html), false)
//Load the file //Load the file
data, _ := loadJson("weather.json") data, _ := loadJson("weather.json")

Loading…
Cancel
Save