utils

package
v0.0.0-...-c9cb955 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadCSV

func LoadCSV(pool *pgxpool.Pool, csvFilePath string) error

LoadCSV loads the CSV file into the specified table in the database

func SendError

func SendError(w http.ResponseWriter, statusCode int, err error)

SendError sends a JSON error response with the given status code and error message

func SendJSON

func SendJSON(w http.ResponseWriter, statusCode int, message string, data interface{})

SendJSON sends a JSON response with the given status code, message, and data

Types

type CsvSource

type CsvSource struct {
	// contains filtered or unexported fields
}

CsvSource implements the pgx.CopyFromSource interface

func (*CsvSource) Err

func (s *CsvSource) Err() error

func (*CsvSource) Next

func (s *CsvSource) Next() bool

func (*CsvSource) Values

func (s *CsvSource) Values() ([]interface{}, error)

type JSONResponse

type JSONResponse struct {
	Status  string      `json:"status"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

JSONResponse represents the structure of a typical JSON response

type Logger

type Logger struct {
	*log.Logger
}

Logger represents a logger instance.

func NewLogger

func NewLogger(prefix string) *Logger

NewLogger creates a new logger instance.

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Debug logs a debug message.

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

Error logs an error message.

func (*Logger) Fatal

func (l *Logger) Fatal(format string, v ...interface{})

Fatal logs a fatal error message and exits the program.

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info logs an informational message.

Jump to

Keyboard shortcuts

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