Mercurial > public > pacobot
comparison auth/config.go @ 8:e9df3bb010f4
fix issues
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 13 Mar 2025 17:41:42 +0000 |
parents | cmd/config.go@4deabe76bd7f |
children |
comparison
equal
deleted
inserted
replaced
7:a8aab75f68c9 | 8:e9df3bb010f4 |
---|---|
1 package auth | |
2 | |
3 import ( | |
4 "encoding/json" | |
5 "io" | |
6 "log" | |
7 "os" | |
8 ) | |
9 | |
10 func ReadConfig() Config { | |
11 file, err := os.Open(".config.json") | |
12 | |
13 if err != nil { | |
14 log.Fatalf("Error opening file: %v", err) | |
15 } | |
16 | |
17 defer file.Close() | |
18 | |
19 bytes, err := io.ReadAll(file) | |
20 | |
21 if err != nil { | |
22 log.Fatalf("Error reading file: %v", err) | |
23 } | |
24 | |
25 var config Config | |
26 | |
27 err = json.Unmarshal(bytes, &config) | |
28 if err != nil { | |
29 log.Fatalf("Error decoding JSON: %v", err) | |
30 } | |
31 | |
32 return config | |
33 } |