main.go: add argument parsing for config path
This commit is contained in:
parent
94770ef25c
commit
892c4b27ac
1 changed files with 6 additions and 1 deletions
7
main.go
7
main.go
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
|
@ -12,7 +13,11 @@ type tomlConfig struct {
|
|||
var config tomlConfig
|
||||
|
||||
func main() {
|
||||
_, err := toml.DecodeFile("config.toml", &config)
|
||||
var configPath string
|
||||
flag.StringVar(&configPath, "config", "config.toml", "path to config file")
|
||||
flag.Parse()
|
||||
|
||||
_, err := toml.DecodeFile(configPath, &config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue