71a6bc4aa4
- 分类管理:支持分类的增删改查 - 单词管理:支持单词的增删改查,包含音标、释义、例句等字段 - 更新 README 项目说明 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
24 lines
600 B
Go
24 lines
600 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kelseyhightower/envconfig"
|
|
)
|
|
|
|
// Config holds all application configuration loaded from environment variables.
|
|
type Config struct {
|
|
AppEnv string `envconfig:"APP_ENV" default:"development"`
|
|
HTTPAddr string `envconfig:"HTTP_ADDR" default:":8080"`
|
|
DatabaseURL string `envconfig:"DATABASE_URL" required:"true"`
|
|
}
|
|
|
|
// Load parses environment variables into Config.
|
|
func Load() (*Config, error) {
|
|
var cfg Config
|
|
if err := envconfig.Process("", &cfg); err != nil {
|
|
return nil, fmt.Errorf("failed to load config: %w", err)
|
|
}
|
|
return &cfg, nil
|
|
}
|