feat: string-unpack api
This commit is contained in:
24
cmd/api/config.go
Normal file
24
cmd/api/config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DSN string `envconfig:"DSN" default:"postgresql://postgres:postgres@postgres:5432/postgres?sslmode=disable"`
|
||||
ReconnectTimeout time.Duration `envconfig:"RECONNECT_TIMEOUT" default:"2s"`
|
||||
}
|
||||
|
||||
func (c *Config) Parse() error {
|
||||
flag.StringVar(&c.DSN, "DSN", "", "postgresql DSN")
|
||||
flag.Parse()
|
||||
|
||||
if err := envconfig.Process("", c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user