27 lines
642 B
Go
27 lines
642 B
Go
|
|
package config
|
||
|
|
|
||
|
|
import "os"
|
||
|
|
|
||
|
|
type Config struct {
|
||
|
|
Port string
|
||
|
|
DBDSN string
|
||
|
|
InternalServiceKey string
|
||
|
|
PurchaserServiceURL string
|
||
|
|
}
|
||
|
|
|
||
|
|
func Load() *Config {
|
||
|
|
return &Config{
|
||
|
|
Port: getEnv("PORT", "8083"),
|
||
|
|
DBDSN: getEnv("DB_DSN", "root:muyu2026@tcp(127.0.0.1:3306)/muyu_wms?parseTime=true&charset=utf8mb4"),
|
||
|
|
InternalServiceKey: getEnv("INTERNAL_SERVICE_KEY", "dev-internal-key"),
|
||
|
|
PurchaserServiceURL: getEnv("PURCHASER_SERVICE_URL", "http://localhost:8082"),
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func getEnv(key, fallback string) string {
|
||
|
|
if v := os.Getenv(key); v != "" {
|
||
|
|
return v
|
||
|
|
}
|
||
|
|
return fallback
|
||
|
|
}
|