util

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WorkingDirectory = workingDirectory()
	ExecuteDirectory = executorDirectory()
	TempDirectory    = os.TempDir()
	StringBuilder    = strings.Builder{}
)
View Source
var (
	CreateCommand func(command string) *exec.Cmd
)
View Source
var (
	MessageList []ErrorMessage
)

Functions

func AbsPath

func AbsPath(file_ string) string

// e.g. // a.txt -> /home/xxx/a.txt // Makefile -> D:/SOFT/CODE/Makefile

func CopyFile

func CopyFile(src string, dst string)

func CreatFile

func CreatFile(src string, data string)

func DeleteFile

func DeleteFile(src string)

func EmitError added in v0.0.3

func EmitError(n int, msg string)

func ErrorHandler added in v0.0.3

func ErrorHandler(err ErrorMessage)

func ExecuteCommand added in v0.0.3

func ExecuteCommand(command string) int

func ExecuteCommandResult added in v0.0.3

func ExecuteCommandResult(command string) string

func ExecuteCommandSilent added in v0.0.3

func ExecuteCommandSilent(command string) int

func ExecuteCommandSilentResult added in v0.0.3

func ExecuteCommandSilentResult(command string) string

func FileLogger

func FileLogger(src string)

func Filter added in v0.0.3

func Filter[T any](array []T, callback func(T) bool) []T

func KillByName added in v0.0.3

func KillByName(name string)

func Map added in v0.0.3

func Map[T any](array []T, callback func(T) T) []T

func NewDebounce added in v0.0.3

func NewDebounce(interval time.Duration) func(f func())

func NewThrottle added in v0.0.3

func NewThrottle(interval time.Duration) func(f func())

func ReadAll

func ReadAll(src string) string

func Recover added in v0.0.3

func Recover(errorHandler func(ErrorMessage))

func Reduce added in v0.0.3

func Reduce[T any, U any](array []T, callback func(U, T) U, init U) U

func TimerStart added in v0.0.3

func TimerStart() *timer

func Timestamp added in v0.0.3

func Timestamp() string

func UnixTime added in v0.0.3

func UnixTime() int64

func WslPathConvent added in v0.0.3

func WslPathConvent(path string) string

cover windows path to wsl path D:\soft\code --> /mnt/d/soft/code

Types

type ErrorMessage added in v0.0.3

type ErrorMessage struct {
	Type int
	Msg  string
}

Jump to

Keyboard shortcuts

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