From 200997976df191159ffab8771a936328bf0ae047 Mon Sep 17 00:00:00 2001 From: grumbulon Date: Mon, 9 Jan 2023 17:30:39 -0500 Subject: [PATCH] added sample config --- config.sample.yaml | 3 +++ internal/configuration.go | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 config.sample.yaml diff --git a/config.sample.yaml b/config.sample.yaml new file mode 100644 index 0000000..eef7035 --- /dev/null +++ b/config.sample.yaml @@ -0,0 +1,3 @@ +server: example.com # does nothing yet +hashingsecret: PasswordHashingSecret +port: 3008 # port the server runs on diff --git a/internal/configuration.go b/internal/configuration.go index 254d9af..189bd67 100644 --- a/internal/configuration.go +++ b/internal/configuration.go @@ -59,20 +59,19 @@ func ReadConfig() (*Config, error) { if data, err = os.ReadFile(filepath.Clean(defaultConfigPath)); err == nil { if err = yaml.Unmarshal(data, &config); err != nil { - return &Config{}, fmt.Errorf("unable to unmarshal config file: %w", err) } + return &config, nil } if data, err = os.ReadFile(filepath.Clean("./config.yaml")); err == nil { if err = yaml.Unmarshal(data, &config); err != nil { - return &Config{}, fmt.Errorf("unable to unmarshal config file: %w", err) } + return &config, nil } return &Config{}, fmt.Errorf("unable to read config file: %w", err) - }