initial import

This commit is contained in:
SourceFellows
2020-08-21 06:26:40 +02:00
commit e223458dd4
423 changed files with 9871 additions and 0 deletions

View File

@ -0,0 +1,28 @@
/*Package main show how to use envconfig.
Start the app in the root folder with:
SERVER_PORT=8080 SERVER_HOST=localhost go run cmd/main.go
*/
package main
import (
"fmt"
"github.com/kelseyhightower/envconfig"
"golang.source-fellows.com/samples/applicationconfiguration"
)
func main() {
cfg := applicationconfiguration.Config{}
err := envconfig.Process("", &cfg)
if err != nil {
panic(err)
}
fmt.Println(cfg.Server.Port)
}

View File

@ -0,0 +1,12 @@
package applicationconfiguration
type Config struct {
Server struct {
Port string `envconfig:"SERVER_PORT" required:"true"`
Host string `envconfig:"SERVER_HOST" required:"true"`
}
Database struct {
Username string `envconfig:"DB_USERNAME"`
Password string `envconfig:"DB_PASSWORD"`
}
}

View File

@ -0,0 +1,5 @@
module golang.source-fellows.com/samples/applicationconfiguration
go 1.14
require github.com/kelseyhightower/envconfig v1.4.0 // indirect

View File

@ -0,0 +1,2 @@
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=