1
0
mirror of https://git.sr.ht/~yotam/shavit synced 2024-11-26 14:34:37 +01:00
shavit/config.go
2019-11-02 14:51:43 +02:00

31 lines
602 B
Go

package main
import (
"fmt"
"io/ioutil"
"github.com/BurntSushi/toml"
)
// Config holds the main configuration data for the server
type Config struct {
SourceDir string `toml:"source"`
TLSCert string `toml:"tls_certificate"`
TLSKey string `toml:"tls_key"`
}
func getConfig(path string) (Config, error) {
raw, err := ioutil.ReadFile(path)
if err != nil {
return Config{}, fmt.Errorf("failed to read config file: %v", err)
}
var cfg Config
err = toml.Unmarshal(raw, &cfg)
if err != nil {
return Config{}, fmt.Errorf("failed to parse config file: %v", err)
}
return cfg, nil
}