-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconfig.go
More file actions
38 lines (33 loc) · 747 Bytes
/
config.go
File metadata and controls
38 lines (33 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"github.com/BurntSushi/toml"
)
type tomlConfig struct {
Port int `toml:"port"`
Addr string `toml:"addr"`
Events map[string]event
Tunnel bool
TunnelName string
}
type event struct {
Cmd string `toml:"cmd"`
Args string `toml:"args"`
}
// loadConfig loads the config.toml file into a tomlConfig struct
func loadConfig() tomlConfig {
var config tomlConfig
if configFile != "" {
if _, err := toml.DecodeFile(configFile, &config); err != nil {
fmt.Println(err)
fmt.Println("failed loading config, going to fallback")
} else {
return config
}
}
if _, err := toml.DecodeFile("./config.toml", &config); err != nil {
fmt.Println(err)
panic("nope")
}
return config
}