Error page + config + docker
This commit is contained in:
parent
7e821296a6
commit
c6c533a503
13 changed files with 110 additions and 31 deletions
29
helpers/config.go
Normal file
29
helpers/config.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pelletier/go-toml"
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
Server struct {
|
||||
Address string `toml:"address"`
|
||||
Port int `toml:"port"`
|
||||
} `toml:"server"`
|
||||
}
|
||||
|
||||
func ParseConfig(filePath string) (*Configuration, error) {
|
||||
var config Configuration
|
||||
data, err := toml.LoadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing config file: %v", err)
|
||||
}
|
||||
|
||||
err = data.Unmarshal(&config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing config file: %v", err)
|
||||
}
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue