utils

package
v0.0.0-...-0d681e9 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToHexPrefix

func ConvertToHexPrefix(hexBytes []byte) string

ConvertToHexPrefix converts a byte slice to a hexadecimal string with "0x" prefix.

func ParseHexWithPrefix

func ParseHexWithPrefix(hexStr string) ([]byte, error)

ParseHexWithPrefix parses a hexadecimal string with "0x" prefix and returns the corresponding byte slice.

func PathExists

func PathExists(path string) bool

func ReadGob

func ReadGob(filePath string, target interface{}) error

ReadGob decodes and loads data from a file into the target variable. It takes the file path and a pointer to the target variable as input. It returns an error if any.

func ReadJson

func ReadJson(filePath string, val interface{}) error

func WriteGob

func WriteGob(data interface{}, filePath string) error

WriteGob encodes and stores data to a file. It takes the data to be stored and the file path as input. It returns an error if any.

func WriteJson

func WriteJson(filePath string, indent string, val interface{}) error

Types

type FileLock

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

FileLock represents a file lock.

func NewFileLock

func NewFileLock(filePath string) (*FileLock, error)

NewFileLock creates a new FileLock instance for the specified file path.

func (*FileLock) Close

func (f *FileLock) Close()

Close closes the lock file.

func (*FileLock) Lock

func (f *FileLock) Lock() error

Lock acquires an exclusive lock on the file.

func (*FileLock) Unlock

func (f *FileLock) Unlock() error

Unlock releases the lock on the file.

Jump to

Keyboard shortcuts

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