util

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const FileSchema = "FILE"

Variables

This section is empty.

Functions

func BuildProxyUrl added in v1.5.1

func BuildProxyUrl(scheme, host, usr, pwd string) *url.URL

BuildProxyUrl builds a proxy url with given host, username and password.

func ByteFmt

func ByteFmt(size int64) string

func CheckDuplicateAndRename

func CheckDuplicateAndRename(path string) (string, error)

CheckDuplicateAndRename rename duplicate file, add suffix (1) (2) ... if file name is a.txt, rename to a (1).txt if directory name is a, rename to a (1) return new name

func CopyDir added in v1.4.0

func CopyDir(source string, target string, excludeDir ...string) error

CopyDir Copy all files to the target directory, if the file already exists, it will be overwritten. Remove target file if the source file is not exist.

func CreateDirIfNotExist added in v1.3.5

func CreateDirIfNotExist(dir string) error

func Dir

func Dir(path string) string

func Filepath

func Filepath(path string, originName string, customName string) string

func IsExistsFile added in v1.3.8

func IsExistsFile(path string) bool

IsExistsFile check file exists and is a file

func MapToStruct

func MapToStruct(s any, v any) error

func Match added in v1.4.0

func Match(pattern string, u string) bool

Match url with pattern by chrome extension match pattern style https://developer.chrome.com/docs/extensions/mv3/match_patterns/

func ParseDataUri added in v1.3.8

func ParseDataUri(uri string) (string, []byte)

ParseDataUri parses a data URI and returns the MIME type and decode data.

func ParseSchema

func ParseSchema(url string) string

func ReplaceInvalidFilename added in v1.5.2

func ReplaceInvalidFilename(path string) string

ReplaceInvalidFilename replace invalid path characters

func RmAndMkDirAll added in v1.4.0

func RmAndMkDirAll(path string) error

RmAndMkDirAll remove and create directory, if the directory already exists, it will be overwritten.

func SafeRemove

func SafeRemove(name string) error

SafeRemove remove file safely, ignoring errors if the path does not exist.

Types

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

func NewTimer added in v1.3.1

func NewTimer(used int64) *Timer

func (*Timer) Pause

func (t *Timer) Pause()

func (*Timer) Start

func (t *Timer) Start()

func (*Timer) Used

func (t *Timer) Used() int64

Jump to

Keyboard shortcuts

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