cfg

package
v0.0.0-...-c214036 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = &Configuration{}

Config is the global configuration variable

Functions

func LoadConfiguration

func LoadConfiguration(config *Configuration)

LoadConfiguration loads the configuration from environment variables

Types

type Configuration

type Configuration struct {
	// Application
	Debug  bool   `env:"DEBUG"`
	Port   string `env:"PORT"`
	Name   string `env:"NAME"`
	Domain string `env:"DOMAIN"`

	// Database
	DBHost     string `env:"DB_HOST"`     // Database host address
	DBPort     string `env:"DB_PORT"`     // Database port
	DBUsername string `env:"DB_USERNAME"` // Database username
	DBPassword string `env:"DB_PASSWORD"` // Database password
	DBDatabase string `env:"DB_DATABASE"` // Database name

	// Only required if DEBUG is false
	MailHost     string `env:"MAIL_HOST"`
	MailPort     string `env:"MAIL_PORT"`
	MailSecure   bool   `env:"MAIL_SECURE"`
	MailUsername string `env:"MAIL_AUTH_USERNAME"`
	MailPassword string `env:"MAIL_AUTH_PASSWORD"`
	MailSender   string `env:"MAIL_SENDER"`
	MailReply    string `env:"MAIL_REPLY"`
}

Configuration holds all the configuration settings for the application. It uses struct tags to map environment variables to struct fields.

The reason why database is not separated from the Configuration struct is because there would need to be extra logic to load the database configuration from the environment variables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳