29 lines
525 B
Go
29 lines
525 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
TelegramToken string `json:"telegram_token"`
|
|
GeminiApiKey string `json:"gemini_api_key"`
|
|
GeminiBaseURL string `json:"gemini_base_url"`
|
|
GeminiModel string `json:"gemini_model"`
|
|
}
|
|
|
|
func Load(path string) (*Config, error) {
|
|
file, err := os.Open(path)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer file.Close()
|
|
|
|
var cfg Config
|
|
decoder := json.NewDecoder(file)
|
|
if err := decoder.Decode(&cfg); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &cfg, nil
|
|
}
|