From 2c785a8b136b0e7ba308f1b9371b2b0928be0414 Mon Sep 17 00:00:00 2001 From: aceberg <1502200+aceberg@users.noreply.github.com> Date: Tue, 16 Aug 2022 11:26:50 +0700 Subject: [PATCH] Config defaults --- getconfig.go | 7 ++++++- main.go | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/getconfig.go b/getconfig.go index 905d7cc..d705aee 100644 --- a/getconfig.go +++ b/getconfig.go @@ -6,6 +6,11 @@ import ( ) 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.SetConfigType("env") viper.ReadInConfig() @@ -17,7 +22,7 @@ func get_config(path string) (config Conf) { config.GuiIP = viper.Get("GUIIP").(string) config.GuiPort = viper.Get("GUIPORT").(string) - // fmt.Println(viper.Get("GUIPORT")) + // fmt.Println(viper.Get("DBPATH")) return config } \ No newline at end of file diff --git a/main.go b/main.go index 4282351..947fd6a 100644 --- a/main.go +++ b/main.go @@ -22,9 +22,6 @@ type Conf struct { } func main() { - // iface := "virbr-bw" - // db_path := "data/hosts.db" - newConfig := get_config("./data/config") text := scan_iface(newConfig.Iface)