【文件属性】:
文件名称:envdecode:Go包,用于使用struct标签从环境变量填充结构
文件大小:11KB
文件格式:ZIP
更新时间:2021-05-15 04:52:06
golang environment-variables Go
编码
envdecode是一个Go包,用于从环境变量填充结构。
envdecode使用struct标记将环境变量映射到字段,从而使您可以将所需的任何名称用于环境变量。 envdecode将递归到嵌套结构中,包括指向嵌套结构的指针,但不会envdecode结构分配新的指针。
原料药
完整的API文档可在上。
使用env struct标签定义一个结构:
type Config struct {
Hostname string `env:"SERVER_HOSTNAME,default=localhost"`
Port uint16 `env:"SERVER_PORT,default=8080"`
AWS struct {
ID string `env:"AWS_ACCESS_KEY_ID"`
Sec
【文件预览】:
envdecode-master
----.gitignore(17B)
----go.mod(45B)
----envdecode.go(10KB)
----envdecode_test.go(19KB)
----.travis.yml(41B)
----LICENSE(1KB)
----README.md(3KB)
----example()
--------main.go(595B)