Spaces:
Sleeping
Sleeping
File size: 476 Bytes
c5eab62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
package config
import (
"os"
"github.com/joho/godotenv"
)
var MonicaConfig *Config
// Config 存储应用配置
type Config struct {
MonicaCookie string
BearerToken string
}
// LoadConfig 从环境变量加载配置
func LoadConfig() *Config {
// 尝试加载 .env 文件,但不强制要求文件存在
_ = godotenv.Load()
MonicaConfig = &Config{
MonicaCookie: os.Getenv("MONICA_COOKIE"),
BearerToken: os.Getenv("BEARER_TOKEN"),
}
return MonicaConfig
}
|