Documentation
¶
Overview ¶
Package utils
Index ¶
- Constants
- func ConnectDB(options ...Option) (*pgxpool.Pool, error)
- func CopyFile(source, destination string) error
- func CreateDatabase(pool *pgxpool.Pool, name string) error
- func GetConnPool(useTestDB bool, config *Environment) (*pgxpool.Pool, error)
- func GetDBURL(cfg *Environment) string
- func GetDevDBURL(cfg *Environment) string
- func GetDynamicDBURL(useTestDB bool, cfg *Environment) string
- func GetDynamicDevDBURL(useTestDB bool, cfg *Environment) string
- func GetMigrationDir() string
- func GetRootDir() (string, error)
- func GetSchemaDir() string
- func GetServices() ([]string, error)
- func GetTestDBName(serviceName string) string
- func GetTestDBURL(cfg *Environment) string
- func GetTestDevURL(cfg *Environment) string
- func InstallCurlBinary(name, url string) error
- func InstallGoPackage(name, url string) error
- func IsCommandAvailable(name string) bool
- func IsDirectory(path string) bool
- func IsRootDir() bool
- func IsServiceDir() bool
- func NotImplemented(_ *cobra.Command, _ []string)
- func RunCommand(name string, args ...string) error
- func RunCommandSilent(name string, args ...string) error
- type Config
- type Environment
- type Option
Constants ¶
View Source
const DevDBName = "dev_db"
Variables ¶
This section is empty.
Functions ¶
func GetConnPool ¶
func GetConnPool(useTestDB bool, config *Environment) (*pgxpool.Pool, error)
GetConnPool returns the database connection pool if useTestDB is true, it will connect to the test database if useTestDB is false, it will connect to the production database
func GetDBURL ¶
func GetDBURL(cfg *Environment) string
func GetDevDBURL ¶
func GetDevDBURL(cfg *Environment) string
func GetDynamicDBURL ¶
func GetDynamicDBURL(useTestDB bool, cfg *Environment) string
func GetDynamicDevDBURL ¶
func GetDynamicDevDBURL(useTestDB bool, cfg *Environment) string
func GetMigrationDir ¶
func GetMigrationDir() string
func GetRootDir ¶
func GetSchemaDir ¶
func GetSchemaDir() string
func GetServices ¶
func GetTestDBName ¶
func GetTestDBURL ¶
func GetTestDBURL(cfg *Environment) string
func GetTestDevURL ¶
func GetTestDevURL(cfg *Environment) string
func InstallCurlBinary ¶
func InstallGoPackage ¶
func IsCommandAvailable ¶
func IsDirectory ¶
func IsServiceDir ¶
func IsServiceDir() bool
func NotImplemented ¶
func RunCommand ¶
func RunCommandSilent ¶
Types ¶
type Environment ¶
type Environment struct {
AppEnv string `env:"APP_ENV" envDefault:"development"`
AppName string `env:"APP_NAME,required"`
// Postgres
DBHost string `env:"DB_HOST,required"`
DBPort int `env:"DB_PORT" envDefault:"5432"`
DBUser string `env:"DB_USER,required"`
DBPassword string `env:"DB_PASSWORD,required"`
DBName string `env:"DB_NAME,required"`
DBSSLMode string `env:"DB_SSL_MODE" envDefault:"disable"`
}
func LoadEnv ¶
func LoadEnv() (*Environment, error)
Click to show internal directories.
Click to hide internal directories.