Initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
BotToken string `json:"bot_token"`
|
||||
ChatID string `json:"chat_id"`
|
||||
GeoIP_City string `json:"geoip_city"`
|
||||
GeoIP_ASN string `json:"geoip_asn"`
|
||||
}
|
||||
|
||||
func LoadConfig(file string) (Config, error) {
|
||||
var config Config
|
||||
|
||||
configFile, err := os.Open(file)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("error opening config file: %v", err)
|
||||
}
|
||||
defer configFile.Close()
|
||||
|
||||
err = json.NewDecoder(configFile).Decode(&config)
|
||||
if err != nil {
|
||||
return config, fmt.Errorf("error decoding config file: %v", err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
Reference in New Issue
Block a user