util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeString added in v0.2.0

func DecodeString(data string) ([]byte, error)

DecodeString returns the bytes represented by the base64 string.

func EncodeToString added in v0.2.0

func EncodeToString(data []byte) string

EncodeToString returns the base64 encoding of the bytes.

func GetUnixAddrWithAbsPath

func GetUnixAddrWithAbsPath(path string) (*net.UnixAddr, error)

GetUnixAddrWithAbsPath converts a string path to a net.UnixAddr making the path absolute.

func PrepareLocalAddr

func PrepareLocalAddr(localAddr net.Addr) error

PrepareLocalAddr creates the folders in the path for the localAddr

func RunTasks

func RunTasks(ctx context.Context, tasks ...func(context.Context) error) error

RunTasks concurrently executes multiple tasks and ensures resilience by handling errors and panics. It creates a cancelable context for the tasks, launches them as separate goroutines, and captures any panics or errors that occur. The function waits for all tasks to complete or until an error occurs. If a task is canceled due to the parent context being canceled, it returns the corresponding error. If any task returns an error, that error is returned. Otherwise, it returns nil to indicate success. This function is useful for concurrently executing independent tasks while maintaining application resilience. Errors and panics are logged using the standard log package.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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