-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassets.go
55 lines (50 loc) · 840 Bytes
/
assets.go
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
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"gopkg.in/yaml.v2"
)
type Config struct {
Server struct {
Port string
Prefix string
}
Assets struct {
Chrome struct {
Windows string
Linux string
Mac string
}
Root string
Page struct {
Pay string
Video string
}
}
}
func loadConfig(file string) Config {
log.Println("try to load config file in", file)
yellowBoyConf := Config{}
if isExt := isExists(file); !isExt {
log.Fatal("No config file found")
}
b, err := ioutil.ReadFile(file)
if err != nil {
fmt.Print(err)
}
err = yaml.Unmarshal(b, &yellowBoyConf)
if err != nil {
log.Fatal()
}
log.Println("load Config:", yellowBoyConf)
return yellowBoyConf
}
func isExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
return os.IsExist(err)
}