utils

package
v0.0.0-...-d9e624e Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package utils

Index

Constants

View Source
const DevDBName = "dev_db"

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(options ...Option) (*pgxpool.Pool, error)

ConnectDB connects to the database and verifies that it is reachable.

func CopyFile

func CopyFile(source, destination string) error

func CreateDatabase

func CreateDatabase(pool *pgxpool.Pool, name string) error

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 GetRootDir() (string, error)

func GetSchemaDir

func GetSchemaDir() string

func GetServices

func GetServices() ([]string, error)

func GetTestDBName

func GetTestDBName(serviceName string) string

func GetTestDBURL

func GetTestDBURL(cfg *Environment) string

func GetTestDevURL

func GetTestDevURL(cfg *Environment) string

func InstallCurlBinary

func InstallCurlBinary(name, url string) error

func InstallGoPackage

func InstallGoPackage(name, url string) error

func IsCommandAvailable

func IsCommandAvailable(name string) bool

func IsDirectory

func IsDirectory(path string) bool

func IsRootDir

func IsRootDir() bool

func IsServiceDir

func IsServiceDir() bool

func NotImplemented

func NotImplemented(_ *cobra.Command, _ []string)

func RunCommand

func RunCommand(name string, args ...string) error

func RunCommandSilent

func RunCommandSilent(name string, args ...string) error

Types

type Config

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	DBName   string
	SSLMode  string
}

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)

type Option

type Option func(*Config)

func WithDBName

func WithDBName(name string) Option

func WithHost

func WithHost(host string) Option

func WithPassword

func WithPassword(password string) Option

func WithPort

func WithPort(count int) Option

func WithUser

func WithUser(user string) Option

Jump to

Keyboard shortcuts

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