-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
27 lines (19 loc) · 611 Bytes
/
Copy pathconfig.go
File metadata and controls
27 lines (19 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"log"
"gopkg.in/ini.v1"
)
func readConfig(file string) (string, int, string, string) {
cfg, err := ini.Load(file)
if err != nil {
log.Fatalf("Error reading settings: %v", err)
}
apiToken := cfg.Section("Weatherflow").Key("Token").String()
deviceID, err := cfg.Section("Weatherflow").Key("DeviceID").Int()
if err != nil {
log.Fatalf("Error converting device ID to int: %v", err)
}
displayName := cfg.Section("Weatherflow").Key("DisplayName").String()
position := cfg.Section("Weatherflow").Key("Position").String()
return apiToken, deviceID, displayName, position
}