util

package module
v0.0.0-...-9693d95 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ReadonlyFilePerm = 0555
	NormalFilePerm   = 0666
	NormalFolerPerm  = 0750
)

Variables

This section is empty.

Functions

func CheckOverwriteFile

func CheckOverwriteFile(name string, overwrite bool) error

CheckOverwriteFile Returns nil if overwrite is true, or an error message if overwrite is false and the file already exists (file overwriting is forbidden).

func PathIsExist

func PathIsExist(name string) (fs.FileInfo, bool)

func PathIsNotExist

func PathIsNotExist(name string) bool

func WrapErrors

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

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

func WriteFile

func WriteFile(name string, data []byte, perm fs.FileMode) error

WriteFile 写檔案, 如果 perm 等于零, 则使用默认权限.

func WriteJSON

func WriteJSON(data interface{}, filename string) error

WriteJSON 把 data 转换为漂亮格式的 JSON 并写入檔案 filename 中。

func WriteTOML

func WriteTOML(data interface{}, filename string) error

Types

type HexString

type HexString = string

func FileSum512

func FileSum512(name string) (HexString, error)

BLAKE2b is faster than MD5, SHA-1, SHA-2, and SHA-3, on 64-bit x86-64 and ARM architectures. https://en.wikipedia.org/wiki/BLAKE_(hash_function)#BLAKE2 https://blog.min.io/fast-hashing-in-golang-using-blake2/ https://pkg.go.dev/crypto/sha256#example-New-File

Jump to

Keyboard shortcuts

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