utils

package
v0.0.0-...-ac40b45 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB float64 = 1e3
	MB float64 = 1e6
	GB float64 = 1e9
	TB float64 = 1e12
	PB float64 = 1e15
	EB float64 = 1e18
)

KB to EB bytes definition, uses x1000

Variables

View Source
var Verbose int

Verbose defines verbosity, user given parameter, default 0: INFO logs

Functions

func ConvertOrderEnumToMongoInt

func ConvertOrderEnumToMongoInt(dir string) int

ConvertOrderEnumToMongoInt converts DataTable enums ("asc" and "desc") to Mongo sorting integer definitions (1,-1)

func ErrorLog

func ErrorLog(format string, v ...interface{})

ErrorLog prints error logs, but not exit the process like log.Fatal

func ErrorResponse

func ErrorResponse(c *gin.Context, msg string, err error, req string)

ErrorResponse returns error response with given msg and error

func GetSearchBuilderBson

func GetSearchBuilderBson(sb *models.SearchBuilderRequest) bson.M

GetSearchBuilderBson iterates over all criteria(s) and creates "AND"/"OR" bson.M query

func InfoLogV0

func InfoLogV0(format string, v ...interface{})

InfoLogV0 prints logs with verbosity >= 0

func InfoLogV1

func InfoLogV1(format string, v ...interface{})

InfoLogV1 prints logs with verbosity >= 1

func InfoLogV2

func InfoLogV2(format string, v ...interface{})

InfoLogV2 prints logs with verbosity >= 2

Types

type ErrorResponseStruct

type ErrorResponseStruct struct {
	Status  int               `json:"status"`
	Message string            `json:"message"`
	Data    map[string]string `json:"data"`
	Request any               `json:"request"`
}

ErrorResponseStruct custom response struct, used in case of error

Jump to

Keyboard shortcuts

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