improve fault tolerance and OS compat beyond linux

This commit is contained in:
ari melody 2026-07-24 09:54:54 +01:00
parent 8e4f353be1
commit 75bd36a332
Signed by: ari
GPG key ID: CF99829C92678188
3 changed files with 30 additions and 20 deletions

View file

@ -85,12 +85,12 @@ func New(ctx context.Context, opts ServiceOptions) (*Service, error) {
var config serviceConfig
if configFile, err := os.OpenFile(path.Join(DATA_PATH, "twitch-config.json"), os.O_CREATE | os.O_RDWR, 0600); err != nil {
log.Fatalf("Failed to open twitch-config.json: %v", err)
return nil, fmt.Errorf("Failed to open twitch-config.json: %v", err)
} else {
defer configFile.Close()
// TODO: write template file if empty
if err := json.NewDecoder(configFile).Decode(&config); err != nil {
log.Fatalf("Failed to read twitch-config.json: %v", err)
return nil, fmt.Errorf("Failed to read twitch-config.json: %v", err)
}
}