30 lines
490 B
Go
30 lines
490 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
type SevenkeysConfig struct {
|
|
DatabaseConfig mysql.Config `json:"DatabaseConfig"`
|
|
CardtraderToken string `json:"CardtraderToken"`
|
|
}
|
|
|
|
func ReadConfigFromFile(filename string) SevenkeysConfig {
|
|
bytes, err := os.ReadFile(filename)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
var config SevenkeysConfig
|
|
err = json.Unmarshal(bytes, &config)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
return config
|
|
}
|