revert back to multiconfig

This commit is contained in:
vcptr committed 2020-01-03 09:26:48 +08:00
1 parent bda694dd8e
commit 8896ffdea8
19 files changed
+557 -83

No files matched your search

+12 -1
View File
@@ -38,7 +38,9 @@ func findOffset(b []byte, o int) *offset {
return &offset{line: line, char: char}
}
func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
// DecodeJSONConfig reads from reader and decode the config into *conf.Config
// syntax error could be detected.
func DecodeJSONConfig(reader io.Reader) (*conf.Config, error) {
jsonConfig := &conf.Config{}
jsonContent := bytes.NewBuffer(make([]byte, 0, 10240))
@@ -62,6 +64,15 @@ func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
return nil, newError("failed to read config file").Base(err)
}
return jsonConfig, nil
}
func LoadJSONConfig(reader io.Reader) (*core.Config, error) {
jsonConfig, err := DecodeJSONConfig(reader)
if err != nil {
return nil, err
}
pbConfig, err := jsonConfig.Build()
if err != nil {
return nil, newError("failed to parse json config").Base(err)