22 lines
426 B
Go
22 lines
426 B
Go
|
package config
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"log"
|
||
|
)
|
||
|
|
||
|
var ErrFailedToParseConfig = errors.New("unable to cast into usable configuration")
|
||
|
|
||
|
func Parse(filePath string) (*MemConfig, error) {
|
||
|
fileConfig, err := parseFile(filePath)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
memConfig, castingErrs := parseConfig(fileConfig)
|
||
|
if !castingErrs.Check() {
|
||
|
log.Print(castingErrs)
|
||
|
return nil, ErrFailedToParseConfig
|
||
|
}
|
||
|
return memConfig, nil
|
||
|
}
|