Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(s Base64String) ([]byte, error)
- func CheckFileName(tempFile string) error
- func CheckTime(layout, value string) error
- func CopyAndLockFile(dstPath, srcPath string) error
- func CopyAndUnlockFile(dstPath, srcPath string) error
- func CopyFile(dstPath, srcPath string) error
- func CreateFile(filePath string, src io.Reader) error
- func CreateReturnFile(filePath string, src io.Reader) (*os.File, error)
- func DeleteFiles(files []string) (err error)
- func DirIsEmpty(dirpath string) (ok bool, err error)
- func DirIsNotEmpty(dirpath string) (ok bool, err error)
- func GetExePath() string
- func GetRegularFiles(folder string) (files []string, err error)
- func IsRegularFile(name string) (ok bool, err error)
- func LockFile(name string) error
- func Mkdir(name string) error
- func MkdirIfNotExists(name string) error
- func OneWaySyncDir(srcDir, dstDir string) error
- func PathExists(name string) bool
- func PathNotExists(name string) (ok bool)
- func SamePath(path1, path2 string) (yes bool, err error)
- func UnlockFile(name string) error
- func WrapErrors(allErrors ...error) (wrapped error)
- func WriteFile(name string, data []byte, perm fs.FileMode) error
- func WriteJSON(data interface{}, filename string) error
- func WriteReadonlyFile(name string, data []byte) error
- func WriteTOML(data interface{}, filename string) error
- type Base64String
- type HexString
Constants ¶
View Source
const ( ReadonlyFilePerm = 0555 NormalFilePerm = 0666 NormalFolerPerm = 0750 )
Variables ¶
View Source
var Separator = string(filepath.Separator)
Functions ¶
func Base64Decode ¶
func Base64Decode(s Base64String) ([]byte, error)
func CopyAndLockFile ¶
func CopyAndUnlockFile ¶
func CreateFile ¶
CreateFile 把 src 的数据写入 filePath, 自动关闭 file.
func CreateReturnFile ¶
CreateReturnFile 把 src 的数据写入 filePath 会自动创建或覆盖文件,返回 file, 要记得关闭资源。
func DeleteFiles ¶
func DirIsEmpty ¶
func DirIsNotEmpty ¶
func GetExePath ¶
func GetExePath() string
GetExePath returns the path name for the executable that started the current process.
func GetRegularFiles ¶
func IsRegularFile ¶
func MkdirIfNotExists ¶
MkdirIfNotExists 创建資料夹, 忽略 ErrExist. 在 Windows 里, 文件夹的只读属性不起作用, 为了统一行为, 不把文件夹设为只读.
func OneWaySyncDir ¶
func PathExists ¶
func WriteReadonlyFile ¶
WriteReadonlyFile 写檔案, 同时把檔案设为只读.
Types ¶
type Base64String ¶
type Base64String = string
func Base64Encode ¶
func Base64Encode(data []byte) Base64String
type HexString ¶
type HexString = string
func FileSum512 ¶
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
Click to show internal directories.
Click to hide internal directories.