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.
30 lines
428 B
Go
30 lines
428 B
Go
3 years ago
|
package application
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/BurntSushi/toml"
|
||
|
|
||
|
)
|
||
|
|
||
|
type Configuration struct {
|
||
|
Port int64
|
||
|
Host string
|
||
|
Path string
|
||
|
}
|
||
|
|
||
|
func (c *Configuration) address() string {
|
||
|
return fmt.Sprintf("%s:%d", c.Host, c.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
|
||
|
}
|