Skip to content

GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.

488 B
Raw Blame
package utils

import "github.com/spf13/viper"

// LoadConfig reads configuration from a .env-style file in the given path.
// If a custom name is supplied, it is used as the config name; otherwise ".env" is used.
func LoadConfig(path string, name ...string) error {
	viper.AddConfigPath(path)
	if len(name) > 0 && name[0] != "" {
		viper.SetConfigName(name[0])
	} else {
		viper.SetConfigName(".env")
	}

	viper.SetConfigType("env")
	viper.AutomaticEnv()

	return viper.ReadInConfig()
}