Documentation ¶
Index ¶
Constants ¶
View Source
const ( // EngineMySQL contains a string used to identify a MySQL database engine. EngineMySQL = "mysql" // EnginePostgres contains a string used to identify a Postgres database engine. EnginePostgres = "postgres" // EngineSQLite contains a string used to identify a SQLite database engine. EngineSQLite = "sqlite" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Environment string `env:"ENVIRONMENT" envDefault:"staging"` Name string `env:"APPLICATION_NAME,required"` Port int `env:"APPLICATION_PORT" envDefault:"3030"` }
Config is used to configure an application metadata.
type DataSourceName ¶ added in v0.5.0
type DataSourceName interface { // DSN returns the data source name as a string. DSN() string }
DataSourceName holds a method to return the data source name that allows establishing a connection with a database.
type Database ¶
type Database struct { Engine string `json:"engine" env:"ENGINE" envDefault:"mysql"` Host string `json:"host" env:"HOST"` User string `json:"user" env:"USER"` Password string `json:"password" env:"PASSWORD"` Port uint `json:"port" env:"PORT" envDefault:"3306"` Name string `json:"name" env:"NAME,notEmpty"` Charset string `json:"charset" env:"CHARSET" envDefault:"utf8mb4"` }
Database contains the information needed to establish connection with a database. It usually describes a config file structure (JSON/YAML) or the environment variables that should be read.
Developers use this data type to configure specific database services: type Application struct { UserDB Database `json:"user_db" envPrefix:"USER_DB_"` DataDB Database `json:"data_db" envPrefix:"DATA_DB_"` }
Read more information about environment variables loader from caarlos0's library: https://github.com/caarlos0/env
Click to show internal directories.
Click to hide internal directories.