utils

package
v0.0.0-...-5c0e286 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Valid     = 1
	Invalid   = 0
	TokenKey  = "oceanProjectTokenKey"
	UserIDKey = "oceanProjectUserIdKey"
)

user state

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, item string) bool

判断切片中是否包含查所要的元素

func Decompress

func Decompress(tarball, target string) error

解压文件 param1: tarball: 压缩文件路径 param2: target: 解压目标路径

func DeleteFile

func DeleteFile(path string) error

删除文件

func DownloadFile

func DownloadFile(url, path, name string) error

通过一个http url下载文件, 文件路径和文件名字

func DownloadFileToWriter

func DownloadFileToWriter(url string, writer io.Writer) error

通过一个http url下载文件, 文件路径和文件名字

func GetFileNameByUrl

func GetFileNameByUrl(url string) string

通过http url下 获取文件名字

func GetRandomString

func GetRandomString() string

生成一个随机字符串

func GetValueFromNestedMap

func GetValueFromNestedMap(m map[string]interface{}, key string) (interface{}, bool)

func IsFileExist

func IsFileExist(path string) bool

判断文件是否存在

func IsHttpUrl

func IsHttpUrl(url string) bool

func Md5

func Md5(str string) string

md5加密

func ReadFile

func ReadFile(path string) ([]byte, error)

func RenameFile

func RenameFile(oldPath, newPath string) error

修改文件名字

func StructTransform

func StructTransform(a, b any) error

func TimeParse

func TimeParse(timeStr string) (time.Time, error)

func YamlToJson

func YamlToJson(yamlDatas ...string) (string, error)

yaml to json

Types

type File

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

func NewFile

func NewFile(path, name string, resume bool) (*File, error)

func (*File) ClearFileContent

func (f *File) ClearFileContent() error

func (*File) Close

func (f *File) Close() error

func (*File) GetFileFullPath

func (f *File) GetFileFullPath() string

func (*File) GetFileName

func (f *File) GetFileName() string

func (*File) GetFilePath

func (f *File) GetFilePath() string

func (*File) Read

func (f *File) Read() ([]byte, error)

func (*File) Write

func (f *File) Write(chunk []byte) error

Jump to

Keyboard shortcuts

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