YoyoGo v1.8.1 发布,更新配置读取环境变量
Features
- Get config value for DSL, that support key or ref object.
Such as YAML:
env: ${CUSTOM_ENV}
profile:
dns: ${REMOTE_HOST}
ip: ${REMOTE_IP:10.0.1.12}
namespace: ${MYNAMESPACE:space.localhost}
Go Example
type Profile struct {
DNS string `config:"dns"`
IP string `config:"ip"`
NS string `config:"namespace"`
}
config := abstractions.NewConfigurationBuilder().
AddEnvironment().
AddYamlFile("config").Build()
config.GetConfigObject("profile", &profile)
assert.Equal(t, profile.NS, "space.yoyogo.run")
assert.Equal(t, profile.DNS, "my host")
assert.Equal(t, profile.IP, "10.0.1.12")
or
env := config.Get("env")
dns := config.Get("profile.dns")
ip := config.Get("profile.ip")
assert.Equal(t, env, "my env variable")
assert.Equal(t, dns, "my host")
assert.Equal(t, ip, "10.0.1.12")
YoyoGo 是一个用 Go 编写的简单,轻便,快速的微服务框架,目前已实现了Web框架的能力,但是底层设计已支持多种服务架构。
特性
- 漂亮又快速的路由器
- 中间件支持 (handler func & custom middleware)
- 对 REST API 友好
- 支持 MVC 模式
- 受到许多出色的 Go Web 框架的启发