Notes2/config.go
2024-11-27 21:41:48 +01:00

41 lines
553 B
Go

package main
import (
// Standard
"encoding/json"
"fmt"
"os"
)
type Config struct {
Network struct {
Address string
Port int
}
Database struct {
Host string
Port int
Db string
Username string
Password string
}
JWT struct {
Secret string
ExpireDays int
}
}
func readConfig() (err error) {
var configData []byte
fname := fmt.Sprintf("%s/.config/notes2.json", os.Getenv("HOME"))
configData, err = os.ReadFile(fname)
if err != nil {
return
}
err = json.Unmarshal(configData, &config)
return
}