-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.go
More file actions
34 lines (29 loc) · 729 Bytes
/
Copy pathsettings.go
File metadata and controls
34 lines (29 loc) · 729 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
28
29
30
31
32
33
34
package main
import (
"fmt"
"io/ioutil"
"log"
"gopkg.in/yaml.v2"
)
type Settings struct {
LoginToken string `yaml:"login_token"`
Domain string `yaml:"domain"`
SubDomain string `yaml:"sub_domain"`
Type string `yaml:"type"`
IPService string `yaml:"ip_service"`
Ttl int `yaml:"ttl"`
}
func Load(path string, settings *Settings) error {
data, err := ioutil.ReadFile(path)
if err != nil {
fmt.Println("Error occurs while reading config file, please make sure config file exists!")
return err
}
err = yaml.Unmarshal(data, settings)
log.Println(settings)
if err != nil {
fmt.Println("Error occurs while unmarshal config file, please make sure config file correct!")
return err
}
return nil
}