786b7d3721
- api/: Go(chi) 只读 API 骨架, /healthz + 版本化路由(占位), Dockerfile, 单测 - ingestion/: Python 采集/ETL 包骨架, units 单位归一化(纯函数+测试), adapter 协议 - docker-compose.yml: postgres + redis + minio + api - .github/workflows/ci.yml: Go build/vet/test + Python ruff/pytest - docs/data-contract.md(两端共享契约) + docs/disclaimer.md(不提供购买声明) - migrations/ 占位(M1 起填充) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
31 lines
807 B
Go
31 lines
807 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// Config holds runtime configuration for the OpenGoods API server.
|
|
// Values are read from environment variables with sensible defaults so the
|
|
// server can boot in a local Docker Compose setup without extra configuration.
|
|
type Config struct {
|
|
Addr string
|
|
DatabaseURL string
|
|
RedisURL string
|
|
}
|
|
|
|
// Load reads configuration from the environment.
|
|
func Load() Config {
|
|
return Config{
|
|
Addr: getenv("OPENGOODS_ADDR", ":8080"),
|
|
DatabaseURL: getenv("OPENGOODS_DATABASE_URL", "postgres://opengoods:opengoods@localhost:5432/opengoods?sslmode=disable"),
|
|
RedisURL: getenv("OPENGOODS_REDIS_URL", "redis://localhost:6379/0"),
|
|
}
|
|
}
|
|
|
|
func getenv(key, fallback string) string {
|
|
if v, ok := os.LookupEnv(key); ok && v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|