package application import ( "fmt" "github.com/BurntSushi/toml" ) type ServerConfig struct { Port int64 Host string } type FileConfig struct { Path string } type DatabaseConfig struct { Backend string Connection string } type Configuration struct { Server ServerConfig File FileConfig Database DatabaseConfig } func (c *Configuration) bindAddress() string { return fmt.Sprintf("%s:%d", c.Server.Host, c.Server.Port) } func ConfigFromToml(toml_data string) (*Configuration, error) { var config Configuration _, err := toml.Decode(toml_data, &config) if err != nil { return nil, err } return &config, nil }