utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils provides utility functions for file operations, error handling, and logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst

func CreateDir

func CreateDir(path string) error

CreateDir creates a directory with all parent directories

func DirExists

func DirExists(path string) bool

DirExists checks if a directory exists

func EnsureDir

func EnsureDir(path string) error

EnsureDir ensures a directory exists, creating it if necessary

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func IsEmptyDir

func IsEmptyDir(path string) (bool, error)

IsEmptyDir checks if a directory is empty

func ListDir

func ListDir(path string) ([]os.DirEntry, error)

ListDir lists all entries in a directory

func NewDevelopmentLogger

func NewDevelopmentLogger() (*zerolog.Logger, error)

NewDevelopmentLogger creates a development logger

func NewLogger

func NewLogger(debug bool) (*zerolog.Logger, error)

NewLogger creates a new zerolog logger with the specified level and encoder

func NewProductionLogger

func NewProductionLogger() (*zerolog.Logger, error)

NewProductionLogger creates a production logger

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads a file and returns its content

func ReadFileAsString

func ReadFileAsString(path string) (string, error)

ReadFileAsString reads a file and returns it as a string

func RemoveDir

func RemoveDir(path string) error

RemoveDir removes a directory and all its contents

func RemoveFile

func RemoveFile(path string) error

RemoveFile removes a file

func WriteFile

func WriteFile(path string, content []byte) error

WriteFile writes content to a file, creating directories if needed

Types

type UserError

type UserError struct {
	Message  string
	Solution string
	Err      error
}

UserError represents an error with a user-friendly message and solution

func NewUserError

func NewUserError(message, solution string, err error) *UserError

NewUserError creates a new UserError

func (*UserError) Error

func (e *UserError) Error() string

func (*UserError) Unwrap

func (e *UserError) Unwrap() error

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new ValidationError

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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