init
This commit is contained in:
commit
2586161abd
49 changed files with 4171 additions and 0 deletions
22
config/parse.go
Normal file
22
config/parse.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"emperror.dev/errors"
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
func Parse(filename string) (Config, error) {
|
||||
var c Config
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return Config{}, errors.Wrap(err, "reading config file")
|
||||
}
|
||||
|
||||
err = toml.Unmarshal(b, &c)
|
||||
if err != nil {
|
||||
return c, errors.Wrap(err, "unmarshaling config file")
|
||||
}
|
||||
return c, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue