utils

package
v0.0.0-...-61fb44a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTAG = iota
	InfoTAG
	DebugTAG
)

tag definitions

Variables

This section is empty.

Functions

func GetTimeStamp

func GetTimeStamp() string

GetTimeStamp returns the current UNIX timestamp

func GracefulExit

func GracefulExit(context string, err error)

GracefulExit exits gracefully without panicking

func Log

func Log(context, message string, TAG int)

Log logs to the console with your custom TAG

func LogDebug

func LogDebug(context, template string, args ...interface{})

LogDebug logs debug messages to console

func LogError

func LogError(context string, err error)

LogError logs type error to console

func LogInfo

func LogInfo(context, template string, args ...interface{})

LogInfo logs information to the console

Types

type FileReader

type FileReader[T any] struct {
	// contains filtered or unexported fields
}

FileReader is a structure for reading files in batches of lines reading files in this manner alleviates the stress on memory and garbage collector

func NewFileReader

func NewFileReader[T any](filename string) *FileReader[T]

NewFileReader returns a new file reader object

func (*FileReader[T]) Close

func (r *FileReader[T]) Close() error

Close closes the file reader object

func (*FileReader[T]) ReadLines

func (r *FileReader[T]) ReadLines(count uint64) ([]*T, error)

ReadLines reads the specified number of lines from the file (if possible) and binds each line to a specific JSON object specified by the generic parameter

Jump to

Keyboard shortcuts

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