You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
622 B
Go
29 lines
622 B
Go
package config
|
|
|
|
import (
|
|
"flag"
|
|
|
|
"github.com/kelseyhightower/envconfig"
|
|
)
|
|
|
|
type ServiceConfig struct {
|
|
LogLevel string `default:"INFO"`
|
|
Port int `default:"5002"`
|
|
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`
|
|
Env string `default:"dev"`
|
|
}
|
|
|
|
func GetServiceConfig() ServiceConfig {
|
|
var sc ServiceConfig
|
|
envconfig.MustProcess("PULLEY", &sc)
|
|
|
|
// Flag overrides
|
|
port := flag.Int("port", sc.Port, "Service port. Default: '5002'")
|
|
logLevel := flag.String("log-level", sc.LogLevel, "Logging level Default:'INFO'")
|
|
flag.Parse()
|
|
sc.Port = *port
|
|
sc.LogLevel = *logLevel
|
|
|
|
return sc
|
|
}
|