func Load(configName string) (*Config, error) {
	v := viper.New()
	var err error
	if _, err = os.Stat("./.env"); err == nil || !os.IsNotExist(err) {
		err := godotenv.Load()
		if err != nil {
			return nil, fmt.Errorf("error loading .env envvars: %w", err)
		}
	}
	envPrefix := strings.ToUpper(configName)
	v.SetEnvPrefix(envPrefix)
	v.SetEnvKeyReplacer(strings.NewReplacer(envPrefix+"_", envPrefix+"_", "_", "__", ".", "_", "-", "_"))
	v.AutomaticEnv()
	v.SetConfigName(strings.ToLower(configName))
	configLocationEnv := fmt.Sprintf("%s_CONFIG_DIR", strings.ToUpper(configName))
	if configDir, isSet := os.LookupEnv(configLocationEnv); isSet {
		v.AddConfigPath(configDir + "/")
	} else if _, err = os.Stat("."); err == nil || !os.IsNotExist(err) {
		v.AddConfigPath(".")
	}
	err = v.ReadInConfig()
	if err != nil {
		return nil, fmt.Errorf("error reading config: %w", err)
	}
	cfg := Default()
	err = v.Unmarshal(&cfg, viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(
		mapstructure.StringToTimeDurationHookFunc(),
		mapstructure.StringToIPHookFunc(),
		StringJSONArrayOrSlicesToConfig(),
	)))
	if err != nil {
		return nil, fmt.Errorf("error unmarshalling config: %w", err)
	}
	err = validate(*cfg)
	if err != nil {
		return nil, err
	}
	return cfg, nil
}
Load Load Configuration from All Sources, starting
1- Environment Variables.	(ex: RUBBAN_KIBANA_HOST=https://kibana:5601"
2- .env file.
3- rubban.(yaml|yml|json|toml)
(values from the earlier overwrite the latter).
package config
import (
	"encoding/json"
	"fmt"
	"os"
	"reflect"
	"strings"
	"github.com/joho/godotenv"
	"github.com/mitchellh/mapstructure"
	"github.com/spf13/viper"
)