mirror of
https://github.com/bestnite/igdb-database.git
synced 2025-06-17 10:13:18 +08:00
start
This commit is contained in:
42
config/config.go
Normal file
42
config/config.go
Normal file
@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Address string `json:"address"`
|
||||
Database struct {
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
User string `json:"user"`
|
||||
Password string `json:"password"`
|
||||
Database string `json:"database"`
|
||||
} `json:"database"`
|
||||
Twitch struct {
|
||||
ClientID string `json:"client_id"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
} `json:"twitch"`
|
||||
WebhookSecret string `json:"webhook_secret"`
|
||||
ExtralUrl string `json:"extral_url"`
|
||||
}
|
||||
|
||||
var c *Config
|
||||
|
||||
func init() {
|
||||
jsonBytes, err := os.ReadFile("config.json")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read config.json: %v", err)
|
||||
}
|
||||
c = &Config{}
|
||||
err = json.Unmarshal(jsonBytes, c)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to unmarshal config.json: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func C() *Config {
|
||||
return c
|
||||
}
|
Reference in New Issue
Block a user