mirror of
https://github.com/anotherhadi/iknowyou.git
synced 2026-04-12 00:47:26 +02:00
don't crash when config is empty
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -86,6 +87,10 @@ func Load(path string) (*Config, error) {
|
||||
dec := yaml.NewDecoder(f)
|
||||
dec.KnownFields(true)
|
||||
if err := dec.Decode(&cfg); err != nil {
|
||||
if err == io.EOF {
|
||||
log.Printf("config: %q is empty, starting with empty config", path)
|
||||
return Default(), nil
|
||||
}
|
||||
return nil, fmt.Errorf("config: decode: %w", err)
|
||||
}
|
||||
return &cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user