start
This commit is contained in:
parent
2c094876c8
commit
9d890ea675
8 changed files with 92 additions and 0 deletions
29
config/config.go
Normal file
29
config/config.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
toml "github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
type TelegramConfig struct {
|
||||
APIKey string `toml:"api_key"`
|
||||
AdminID string `toml:"admin_id"`
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Type string `toml:"type"`
|
||||
Path string `toml:"path"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Telegram TelegramConfig
|
||||
Storage StorageConfig
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
var cfg Config
|
||||
_, err := toml.DecodeFile(path, &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue