You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
850 B

package config
import (
"fmt"
"github.com/BurntSushi/toml"
"io/ioutil"
"os"
)
// Config is a struct with my config
type Config struct {
SL struct {
APIKey string
RefreshDelay int64
SiteID int
APIURL string
}
Clock struct {
TimeFormat string
}
Weather struct {
URL string
RefreshDelay int64
}
Pollen struct {
URL string
RefreshDelay int64
CityName string
}
Watersensor struct {
Host string
RefreshDelay int64
}
}
func New(configFile string) Config {
var config Config
// Read the configfile
file, err := ioutil.ReadFile(configFile)
if err != nil {
fmt.Printf("File error: %v\n", err)
os.Exit(1)
}
// Parse config
if _, err := toml.Decode(string(file), &config); err != nil {
fmt.Printf("Config error: %v\n", err)
os.Exit(1)
}
return config
}