Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Validation Errors ErrMissingHost = errors.New("database host is required") ErrInvalidPort = errors.New("database port must be greater than zero") ErrMissingUser = errors.New("database user is required") ErrMissingDBName = errors.New("database name is required") // Connection Errors ErrInvalidConfig = errors.New("invalid database configuration") ErrFailedConnect = errors.New("failed to connect to database") ErrFailedPing = errors.New("failed to ping database") ErrNilDatabase = errors.New("database connection is nil") ErrFailedClose = errors.New("failed to close database connection") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Host specifies the database server's hostname or IP address.
// Example: "localhost" or "192.168.1.100".
Host string `toml:"host" mapstructure:"host"`
// Port defines the port on which the database server is listening.
// Default PostgreSQL port: 5432.
Port int `toml:"port" mapstructure:"port"`
// User represents the database username for authentication.
// Example: "postgres" for a default PostgreSQL setup.
User string `toml:"user" mapstructure:"user"`
// Password is the database user's password.
Password string `toml:"password" mapstructure:"password"`
// DBName specifies the name of the PostgreSQL database to connect to.
DBName string `toml:"dbname" mapstructure:"dbname"`
// SSLMode determines whether to use SSL/TLS for database connections.
// Example values: "disable", "require", "verify-full".
// If empty, it defaults to "disable".
SSLMode string `toml:"sslmode" mapstructure:"sslmode"`
}
Config represents the database connection settings.
Click to show internal directories.
Click to hide internal directories.