11
Database, User, Password, Table string
14
func (l *JsonCfg) ConfigFrom(path string) error {
15
b, err := ioutil.ReadFile(path)
19
return json.Unmarshal(b, &l)
8
var dbuser, dbpasswd, database string
9
flag.StringVar(&database, "database", "inmemory", "Sql Database connection to use.")
10
flag.StringVar(&dbuser, "dbuser", "", "User for mysql database.")
11
flag.StringVar(&dbpasswd, "dbpasswd", "", "Password for user for mysql database.")
24
flag.StringVar(&config, "config", "", "Database configuration file to read.")
15
if database == "inmemory" {
30
if err := cfg.ConfigFrom(config); err != nil {
31
log.Fatalf("Could not parse config file: %v", err)
33
db = NewMySqlDatabase(cfg.Database, cfg.User, cfg.Password, cfg.Table)
16
35
db = NewInMemoryDb()
18
db = NewMySqlDatabase(database, dbuser, dbpasswd)