You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bog/application/configuration.go

45 lines
635 B
Go

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
}