do configs through env

This commit is contained in:
sm
2013-12-20 23:04:33 -08:00
parent 54489f603a
commit a8e03e721e
2 changed files with 48 additions and 0 deletions
+29
View File
@@ -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
}