Initial commit with user management
This commit is contained in:
commit
a1a928e7cb
98 changed files with 13042 additions and 0 deletions
40
config.go
Normal file
40
config.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue