mirror of
https://github.com/hamburghammer/gmon.git
synced 2024-05-03 22:55:25 +02:00
968bed2c84
This is to have no naming conflicts introducing rule loading.
29 lines
609 B
Go
29 lines
609 B
Go
package config
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/pelletier/go-toml"
|
|
)
|
|
|
|
// TomlConfigLoader handels a toml configuration file
|
|
type TomlConfigLoader struct {
|
|
reader io.Reader
|
|
}
|
|
|
|
// Load implementation of the Loader interface to load the config from the file
|
|
func (tl TomlConfigLoader) Load() (Config, error) {
|
|
data := Config{}
|
|
err := toml.NewDecoder(tl.reader).Decode(&data)
|
|
if err != nil {
|
|
return Config{}, err
|
|
}
|
|
|
|
return data, nil
|
|
}
|
|
|
|
// NewTomlConfigLoader constructor for the TomlConfigLoader struct
|
|
func NewTomlConfigLoader(reader io.Reader) TomlConfigLoader {
|
|
return TomlConfigLoader{reader: reader}
|
|
}
|