config

package
v0.0.0-...-bf86ce8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Environment string `default:"local" env:"ENVIRONMENT"`

	App struct {
		APP struct {
			URL       string `default:"http://localhost" env:"APP_URL"`
			Port      uint   `default:"8080" env:"APP_PORT"`
			Timezone  string `default:"UTC" env:"APP_TIMEZONE"`
			DebugMode bool   `default:"false" env:"APP_DEBUG_MODE"`
		}
		DevMode bool `default:"false" env:"DEV"`
	}

	Database struct {
		Mysql struct {
			Host     string `default:"localhost" env:"DB_HOST"`
			User     string `default:"root" env:"DB_USER"`
			Password string `default:"" env:"DB_PASSWORD"`
			Port     string `default:"3306" env:"DB_PORT"`
			Name     string `env:"DB_NAME"`
		}

		Timeout      time.Duration `default:"5" env:"DB_TIMEOUT"`
		DialTimeout  time.Duration `default:"5" env:"DB_DIAL_TIMEOUT"`
		ReadTimeout  time.Duration `default:"5" env:"DB_READ_TIMEOUT"`
		WriteTimeout time.Duration `default:"5" env:"DB_WRITE_TIMEOUT"`
	}

	Log struct {
		Level  string `env:"LOG_LEVEL" default:"info"`
		Format string `env:"LOG_FORMAT" default:"console"`
	}

	Authentication struct {
		Secret string `env:"AUTHENTICATION_SECRET" default:"default_secret"`
	}
}

Config represents application configuration which can also be set via environment variable during runtime.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from `.env` file in the same directory as the application and populate the Config accordingly.

func LoadTestConfig

func LoadTestConfig() (*Config, error)

LoadTestConfig ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL