util

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile added in v0.2.0

func CopyFile(destPath, sourcePath string) error

https://stackoverflow.com/questions/30376921/how-do-you-copy-a-file-in-go

func FileSha256Hex added in v0.2.0

func FileSha256Hex(name string) (string, error)

FileSha256Hex 返回文件 name 的 hex 字符串。 虽然函数名是 Sha256, 但实际上采用 BLAKE2b 算法。

func FindFile added in v0.2.0

func FindFile(name string) error

FindFile returns a better error massage if cannot find the file.

func IntMin added in v0.2.0

func IntMin(a, b int) int

IntMin computes the minimum of the two int args

func Panic

func Panic(err error)

Panic panics if err != nil

func PathIsExist

func PathIsExist(name string) (bool, error)

PathIsExist 找到名为 name 的文件时返回 true, 否则返回 false

func PathIsNotExist

func PathIsNotExist(name string) (ok bool, err error)

PathIsNotExist 找不到名为 name 的文件时返回 true, 否则返回 false

func Sha256Hex added in v0.2.0

func Sha256Hex(data []byte) string

Sha256Hex 返回 sha256 的 hex 字符串。 虽然函数名是 Sha256, 但实际上采用 BLAKE2b 算法。

func StrIndex added in v0.2.0

func StrIndex(slice []string, item string) int

StrIndex returns the index of a string in the slice. returns -1 if not found.

func StrSliceFilter added in v0.2.0

func StrSliceFilter(arr []string, test func(string) bool) (result []string)

func WrapErrors added in v0.2.0

func WrapErrors(allErrors ...error) (wrapped error)

WrapErrors 把多个错误合并为一个错误.

Types

This section is empty.

Jump to

Keyboard shortcuts

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