This repository was archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
59 lines (49 loc) · 1.18 KB
/
config.go
File metadata and controls
59 lines (49 loc) · 1.18 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"encoding/json"
"io/ioutil"
)
const MAX_PUSH_CONNECTIONS = 4
type Config struct {
Push_url string `json:"push_url"`
API_key string `json:"api_key"`
Refresh int64 `json:"refresh"`
USGS_url string `json:"usgs_url"`
Sources ConfigSources `json:"sources"`
}
type ConfigSources struct {
Image []ConfigImage `json:"image"`
USGS []ConfigUSGS_Site `json:usgs`
}
type ConfigImage struct {
Source string `json:"source"`
Caption string `json:"caption"`
Widget string `json:"widget"`
}
type ConfigUSGS_Site struct {
Site string `json:"site"`
Param string `json:"param"`
Widget string `json:"widget"`
Bars ConfigUSGS_Bars `json:"bars,omitempty"`
}
type ConfigUSGS_Bars struct {
Low ConfigUSGS_Bar `json:"low"`
Current ConfigUSGS_Bar `json:"current"`
High ConfigUSGS_Bar `json:"high"`
}
type ConfigUSGS_Bar struct {
Widget string `json:"widget"`
Value int `json:"value"`
}
func ParseConfig(filename string) (config *Config, err error) {
var b []byte
b, err = ioutil.ReadFile(filename)
if err != nil {
return
}
err = json.Unmarshal(b, &config)
if err != nil {
return
}
return
}