Initial scaffold: Go module, SQLite schema, config loader, Telegram bot with webhook/polling modes
This commit is contained in:
24
internal/config/loader.go
Normal file
24
internal/config/loader.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
BotToken string `json:"bot_token"`
|
||||
ProxyAddr string `json:"proxy_address"`
|
||||
LogLevel string `json:"log_level"`
|
||||
}
|
||||
|
||||
func Load(path string) (*Config, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var cfg Config
|
||||
if err := json.Unmarshal(data, &cfg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user