initial commit

This commit is contained in:
2025-04-18 12:04:03 +10:00
commit 57385cbaed
11 changed files with 168 additions and 0 deletions

20
config/config.go Normal file
View File

@@ -0,0 +1,20 @@
package config
import (
"fmt"
"github.com/spf13/viper"
)
func ReadConfig() error {
configPath := viper.GetString("config")
if configPath == "" {
return fmt.Errorf("config file path is empty")
}
viper.SetConfigFile(configPath)
viper.SetConfigType("yaml")
if err := viper.ReadInConfig(); err != nil {
return fmt.Errorf("reading config file %s: %w", configPath, err)
}
return nil
}

8
config/env.go Normal file
View File

@@ -0,0 +1,8 @@
package config
import "github.com/spf13/viper"
func CollectEnv() {
viper.SetEnvPrefix("NETBOUNCE_")
_ = viper.BindEnv("config", "CONFIG")
}