Beispiel #1
0
// Will try to parse TOML configuration file.
func (c *Conf) Parse(path string) {
	c.loadDefaults()

	if path == "" {
		log.Warn("Configuration file not provided!")
		return
	}

	if _, err := toml.DecodeFile(path, c); err != nil {
		panic(err)
	}
}
Beispiel #2
0
func getToml() {
	if _, err := toml.DecodeFile("./Config/config.toml", &tomlConfig); err != nil {
		log.Fatal(err)
		// return
	}
	if tomlConfig.Debug.Enabled {
		fmt.Printf("Title: %s\n", tomlConfig.Title)
		fmt.Printf("Owner: %s (%s, %s), Born: %s\n",
			tomlConfig.Owner.Name, tomlConfig.Owner.Org, tomlConfig.Owner.Bio,
			tomlConfig.Owner.DOB)

		for serverName, server := range tomlConfig.Servers {
			fmt.Printf("Server: %s (%s, %s)\n", serverName, server.IP, server.DC)
		}
		fmt.Printf("Client data: %v\n", tomlConfig.Clients.Data)
		fmt.Printf("Client hosts: %v\n", tomlConfig.Clients.Hosts)
		fmt.Printf("Agg: %s, \n", tomlConfig.Agg.Server)
		for i, port := range tomlConfig.Agg.Ports {

			fmt.Printf("Port %d is %d\n", i, port)

		}
	}
}