// New initializes a new server instance and loads server.conf file if one // exists, otherwise it'll create a new one. func New(c *config.Config) *Server { log.Println("Generating keypair.") // Generate config if c == nil { c = config.New() if err := c.ParseFile("./server.conf"); err != nil { c = ConfigCreate() } } s := &Server{ id: serverId(), config: c, privateKey: auth.GenerateKeyPair(), // Load from config Motd: c.Get("server.motd"), Cmds: make(map[string]cmd.Cmder), Players: players.New(), Tickers: tickers.New(), } return s }
func ExamplePrettyMap() { c := config.New() c.Parse("a:\n b:2\n c:3\nd:4") m := c.Copy() fmt.Println(config.PrettyMap(m)) // Output: // "a.b": 2 // "a.c": 3 // "d": 4 }