31 lines
779 B
Go
31 lines
779 B
Go
|
package setup
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* IMPORTS
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
import (
|
||
|
"ads/internal/types"
|
||
|
"io/ioutil"
|
||
|
|
||
|
"gopkg.in/yaml.v3"
|
||
|
)
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* METHODS
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
// Erstellt eine Struktur, die die Infos aus der Config-Datei erfasst
|
||
|
func NewUserConfig() types.UserConfig {
|
||
|
return types.UserConfig{}
|
||
|
}
|
||
|
|
||
|
// Extrahiert Inhalte einer YAML Config und parset dies als Struktur
|
||
|
func GetUserConfig(path string, config *types.UserConfig) error {
|
||
|
contents, err := ioutil.ReadFile(path)
|
||
|
if err == nil {
|
||
|
err = yaml.Unmarshal(contents, config)
|
||
|
}
|
||
|
return err
|
||
|
}
|