Documentation
¶
Index ¶
Constants ¶
View Source
const (
// AppConfigFilename is the filename for the app config file
AppConfigFilename = "config.toml"
)
Variables ¶
View Source
var AppFS = afero.NewOsFs()
AppFS is a handle to the filesystem in use
Functions ¶
Types ¶
type AppConfig ¶
type AppConfig struct {
DefaultEnv string `toml:"env"`
}
AppConfig holds the relevant generated app config.toml file variables
type Configuration ¶
type Configuration struct {
// AppPath is the path to the project, set using the init function
AppPath string
// AppName is the name of the application, derived from the path
AppName string
// AppEnvName is the name of the app in environment variable prefix format
// for example "MYAPP" instead of "MyApp".
AppEnvName string
// ActiveEnv is the environment mode currently set by "env" in config.toml
// or APPNAME_ENV environment variable. This mode indicates what section of
// config variables to to load into the config structs.
ActiveEnv string
// ModeViper is a *viper.Viper that has been initialized to:
// Load the active environment section of the AppPath/config.toml file
// Load environment variables with a prefix of APPNAME
// Replace "-" with "_" in environment variable names
ModeViper *viper.Viper
}
Configuration holds app state variables
func InitializeP ¶
func InitializeP(env *pflag.Flag) *Configuration
InitializeP the config but panic if anything goes wrong
func (*Configuration) CheckEnv ¶
func (c *Configuration) CheckEnv() error
CheckEnv outputs an error if no ActiveEnv is found
type DBConfig ¶
type DBConfig struct {
DB string `toml:"db" mapstructure:"db"`
Host string `toml:"host" mapstructure:"host"`
Port int `toml:"port" mapstructure:"port"`
DBName string `toml:"dbname" mapstructure:"dbname"`
User string `toml:"user" mapstructure:"user"`
Pass string `toml:"pass" mapstructure:"pass"`
SSLMode string `toml:"sslmode" mapstructure:"sslmode"`
}
DBConfig holds the configuration variables contained in the config.toml file for the environment currently loaded (obtained from GetDatabaseEnv())
Click to show internal directories.
Click to hide internal directories.