-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconf.go
More file actions
48 lines (40 loc) · 879 Bytes
/
conf.go
File metadata and controls
48 lines (40 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
)
type config struct {
Debug bool
WebHost string
WebPort int
DbHost string
DbPort int
DbName string
StaticPath string
}
var Config = new(config)
func (c *config) HostString() string {
return fmt.Sprintf("%s:%d", c.WebHost, c.WebPort)
}
func (c *config) DbHostString() string {
if c.DbPort > 0 {
return fmt.Sprintf("mongodb://%s:%d", c.DbHost, c.DbPort)
}
return fmt.Sprintf("mongodb://%s", c.DbHost)
}
func (c *config) String() string {
s := "Config:"
s += fmt.Sprintf(" Host: %s,\n", c.HostString())
s += fmt.Sprintf(" DB: %s,\n", c.DbHostString())
s += fmt.Sprintf(" Debug: %v\n", c.Debug)
return s
}
func init() {
// defaults
Config.WebHost = "0.0.0.0"
Config.WebPort = 8080
Config.DbHost = "127.0.0.1"
Config.DbPort = 0
Config.DbName = "kriter_test"
Config.Debug = false
Config.StaticPath = "./static"
}