updated gitignore and missed files

This commit is contained in:
Paul 2020-02-07 07:04:03 +01:00
parent 546f80cfce
commit bd4694bbff
2 changed files with 40 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,2 +1,2 @@
weather
/weather
*.ini

39
cmd/weather/weather.go Normal file
View File

@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
"log"
"git.paulbsd.com/paulbsd/weather/src/config"
"git.paulbsd.com/paulbsd/weather/src/data"
_ "github.com/influxdata/influxdb1-client"
)
func main() {
var c config.Config
var cp string
var err error
flag.StringVar(&cp, "configfile", "weather.ini", "config file to use with fuelprices section")
flag.Parse()
err = config.GetConfig(&c, cp)
if err != nil {
log.Fatal(err)
}
for _, city := range c.WeatherCities {
d, err := data.FetchData(&c, city)
if err != nil {
log.Fatal(err)
}
err = data.SendDataToInflux(&c, d)
if err != nil {
log.Fatal(err)
} else {
log.Println(fmt.Sprintf("Successfully sent data for %s", city))
}
}
}