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) - }