util

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Size2KB   = 2 * 1024
	Size4KB   = 4 * 1024
	Size8KB   = 8 * 1024
	Size16KB  = 16 * 1024
	Size32KB  = 32 * 1024
	Size64KB  = 64 * 1024
	Size128KB = 128 * 1024
	Size256KB = 256 * 1024
	Size512KB = 512 * 1024
	Size1MB   = 1 * 1024 * 1024
	Size10MB  = 10 * 1024 * 1024
	Size100MB = 100 * 1024 * 1024
	Size1GB   = 1 * 1024 * 1024 * 1024
)

Variables

This section is empty.

Functions

func BuildBinary

func BuildBinary(suffix string) error

func DirectoriesInPath

func DirectoriesInPath(path string) ([]string, error)

DirectoriesInPath returns a list of directories in the given path (first-level only).

func DirectoryCreate

func DirectoryCreate(path string) error

DirectoryCreate creates a new directory with the given path

func DirectoryGetHighestVersion

func DirectoryGetHighestVersion(path string) (string, error)

DirectoryGetHighestVersion finds the directory with the highest numeration (e.g., v1, v2, v100, etc.)

func DirectoryIsEmpty

func DirectoryIsEmpty(path string) (bool, error)

DirectoryIsEmpty checks if a directory is empty

func DirectoryRemove

func DirectoryRemove(path string) error

DirectoryRemove deletes the directory and its contents

func FileCopy

func FileCopy(pathSource, pathDestiny string) error

func FileCreate

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

func FileDelete

func FileDelete(path string) error

func FileExpand

func FileExpand(filePath string, tags []FileExpanderTags) error

func FileIsEditable

func FileIsEditable(filename string) bool

func FileRead

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

func FileSizeHuman

func FileSizeHuman(path string) (string, error)

func GenerateRandomMessage

func GenerateRandomMessage(s int) ([]byte, error)

func GenerateRandomStringMessage

func GenerateRandomStringMessage(s int) (string, error)

func GetEnvKeyValue

func GetEnvKeyValue(key string) string

func GetMemoryUsage

func GetMemoryUsage() string

func GetModuleName

func GetModuleName(modPath string) (string, error)

GetModuleName reads a go.mod file from the specified path and returns the module name.

func ParallelFilter added in v0.0.3

func ParallelFilter[T any](items []T, matchFn func(T) bool) []T

func PathExists

func PathExists(path string) (bool, error)

func Pkill

func Pkill(processName string) error

func StringNextVersion

func StringNextVersion(currentVersion string) (string, error)

Types

type FileExpanderTags

type FileExpanderTags struct {
	StartTag   []byte
	EndTag     []byte
	ExpandWith []byte
	Count      int
}

type StructDef

type StructDef struct {
	Name   string
	Fields []StructField
}

StructDef represents the whole struct definition

func StructsExtractFromPackage

func StructsExtractFromPackage(pkgDir string, includePrivate bool, limit int) ([]StructDef, error)

StructsExtractFromPackage scans a package directory and extracts struct definitions includePrivate determines whether to include unexported (private) fields limit specifies the maximum number of structs to extract (0 means no limit)

type StructField

type StructField struct {
	Name string
	Type string
	Tag  string
}

StructField represents a field in a struct

Jump to

Keyboard shortcuts

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