This commit is contained in:
42
config/global.go
Normal file
42
config/global.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// GlobalConfig is config which is used only once in root dir
|
||||
type GlobalConfig struct {
|
||||
Webserver struct {
|
||||
Type string `yaml:"Type"`
|
||||
} `yaml:"Webserver"`
|
||||
|
||||
Assets struct {
|
||||
FromPath string `yaml:"FromPath"`
|
||||
ToPath string `yaml:"ToPath"`
|
||||
Action string `yaml:"Action"`
|
||||
FixTemplate struct {
|
||||
Find string `yaml:"Find"`
|
||||
Replace string `yaml:"Replace"`
|
||||
} `yaml:"FixTemplate"`
|
||||
} `yaml:"Assets"`
|
||||
|
||||
OtherFiles struct {
|
||||
Action string `yaml:"Action"`
|
||||
} `yaml:"OtherFiles"`
|
||||
}
|
||||
|
||||
var Config = new(GlobalConfig)
|
||||
|
||||
func ReadGlobalConfig(filename string) error {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = yaml.Unmarshal(data, Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user