do configs through env
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Configs struct {
|
||||
Verbose bool
|
||||
Dbhost string
|
||||
Dbname string
|
||||
Dbport int
|
||||
Port int
|
||||
}
|
||||
|
||||
func NewConfig() *Configs {
|
||||
return &Configs{
|
||||
Verbose: true,
|
||||
Dbname: "itslog",
|
||||
Dbport: 5432,
|
||||
Port: 80,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Configs) validate() error {
|
||||
if c.Dbhost == "" {
|
||||
return errors.New("must specify dbhost (export ITSLOG_DBHOST=blah.local)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user