driver

package
v0.0.0-...-f309447 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package driver provides database connection management for the CarZone application. It handles PostgreSQL database connections using the lib/pq driver and manages connection lifecycle including initialization, retrieval, and cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB()

CloseDB gracefully closes the database connection pool. This function should be called during application shutdown to ensure all database connections are properly closed and resources are freed. It's typically called using defer in the main function.

func GetDB

func GetDB() *sql.DB

GetDB returns the singleton database connection pool instance. This function provides access to the database connection throughout the application. It returns the same *sql.DB instance that was initialized by InitDB().

Returns:

  • *sql.DB: The database connection pool instance, or nil if not initialized

func InitDB

func InitDB()

InitDB initializes the PostgreSQL database connection pool. It reads database configuration from environment variables and establishes a connection with proper error handling and connection validation. This function should be called once during application startup.

Types

This section is empty.

Jump to

Keyboard shortcuts

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