package config import ( "errors" "os" "path" "git.trj.tw/golang/utils" ) // RecordData - type RecordData struct { Name string `yaml:"name"` Type string `yaml:"type"` } // DomainData - type DomainData struct { Name string `yaml:"name"` Records []RecordData `yaml:"records"` } // Config - type Config struct { URL string `yaml:"url"` VerifyValue string `yaml:"verify_value"` Domains []DomainData `yaml:"domains"` } // LoadConfig - func LoadConfig(p ...string) error { var fp string // set config path if len(p) > 0 && len(p[0]) > 0 { fp = p[0] } else { wd, err := os.Getwd() if err != nil { return err } fp = path.Join(wd, "config.yml") } if exists := utils.CheckExists(fp, false); !exists { return errors.New("config file not exists") } return nil }