Config defaults
This commit is contained in:
parent
3612c47734
commit
2c785a8b13
2 changed files with 6 additions and 4 deletions
|
|
@ -6,6 +6,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func get_config(path string) (config Conf) {
|
func get_config(path string) (config Conf) {
|
||||||
|
viper.SetDefault("IFACE", "eth0")
|
||||||
|
viper.SetDefault("DBPATH", "data/db.sqlite")
|
||||||
|
viper.SetDefault("GUIIP", "localhost")
|
||||||
|
viper.SetDefault("GUIPORT", "8840")
|
||||||
|
|
||||||
viper.SetConfigFile(path)
|
viper.SetConfigFile(path)
|
||||||
viper.SetConfigType("env")
|
viper.SetConfigType("env")
|
||||||
viper.ReadInConfig()
|
viper.ReadInConfig()
|
||||||
|
|
@ -17,7 +22,7 @@ func get_config(path string) (config Conf) {
|
||||||
config.GuiIP = viper.Get("GUIIP").(string)
|
config.GuiIP = viper.Get("GUIIP").(string)
|
||||||
config.GuiPort = viper.Get("GUIPORT").(string)
|
config.GuiPort = viper.Get("GUIPORT").(string)
|
||||||
|
|
||||||
// fmt.Println(viper.Get("GUIPORT"))
|
// fmt.Println(viper.Get("DBPATH"))
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
3
main.go
3
main.go
|
|
@ -22,9 +22,6 @@ type Conf struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// iface := "virbr-bw"
|
|
||||||
// db_path := "data/hosts.db"
|
|
||||||
|
|
||||||
newConfig := get_config("./data/config")
|
newConfig := get_config("./data/config")
|
||||||
|
|
||||||
text := scan_iface(newConfig.Iface)
|
text := scan_iface(newConfig.Iface)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue