config: allow to specify config path directly
It costs us nothing and makes API much more flexible.
This commit is contained in:
parent
d8677844fd
commit
681e0e0a4d
1 changed files with 5 additions and 0 deletions
|
@ -31,6 +31,11 @@ func (c Config) GenerateUserAgent() string {
|
|||
// path for the given netMode.
|
||||
func Load(path string, netMode netmode.Magic) (Config, error) {
|
||||
configPath := fmt.Sprintf("%s/protocol.%s.yml", path, netMode)
|
||||
return LoadFile(configPath)
|
||||
}
|
||||
|
||||
// LoadFile loads config from the provided path.
|
||||
func LoadFile(configPath string) (Config, error) {
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
return Config{}, errors.Wrap(err, "Unable to load config")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue