Impl storage mongo driver and config
This commit is contained in:
24
config/config.go
Normal file
24
config/config.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package config
|
||||
|
||||
import "local/args"
|
||||
|
||||
type Config struct {
|
||||
Port int
|
||||
DBURI string
|
||||
}
|
||||
|
||||
func New() Config {
|
||||
as := args.NewArgSet()
|
||||
|
||||
as.Append(args.INT, "p", "port to listen on", 18114)
|
||||
as.Append(args.STRING, "dburi", "database uri", "mongodb://localhost:27017")
|
||||
|
||||
if err := as.Parse(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return Config{
|
||||
Port: as.GetInt("p"),
|
||||
DBURI: as.GetString("dburi"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user