utils

package
v0.0.0-...-a382c62 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package utils; From https://github.com/cloudreve/Cloudreve/blob/master/pkg/util/io.go

Package utils; From https://github.com/cloudreve/Cloudreve/blob/master/pkg/util/logger.go

Package utils; From https://github.com/cloudreve/Cloudreve/blob/master/pkg/util/path.go

Index

Constants

View Source
const (
	// LevelError 错误
	LevelError = iota
	// LevelWarning 警告
	LevelWarning
	// LevelInformational 提示
	LevelInformational
	// LevelDebug 除错
	LevelDebug
)

Variables

View Source
var Level = LevelDebug

Functions

func BuildConcat

func BuildConcat(str1, str2 string, DBType string) string

BuildConcat 根据数据库类型构建字符串连接表达式

func BuildLogger

func BuildLogger(level string)

BuildLogger 构建logger

func BuildRegexp

func BuildRegexp(search []string, prefix, suffix, condition string) string

BuildRegexp 构建用于SQL查询用的多条件正则

func ContainsString

func ContainsString(s []string, e string) bool

ContainsString 返回list中是否包含

func ContainsUint

func ContainsUint(s []uint, e uint) bool

ContainsUint 返回list中是否包含

func CreatNestedFile

func CreatNestedFile(path string) (*os.File, error)

CreatNestedFile 给定path创建文件,如果目录不存在就递归创建

func DotPathToStandardPath

func DotPathToStandardPath(path string) string

DotPathToStandardPath 将","分割的路径转换为标准路径

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func Extension

func Extension(path string) string

Extension 获取文件扩展名

func FileHasMinSuffix

func FileHasMinSuffix(path string) bool

FileHasMinSuffix 文件第二段后缀是否为`min`

func FillSlash

func FillSlash(path string) string

FillSlash 给路径补全`/`

func FormSlash

func FormSlash(old string) string

FormSlash 将path中的反斜杠'\'替换为'/'

func IsEmpty

func IsEmpty(name string) (bool, error)

IsEmpty 返回给定目录是否为空目录

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes 返回随机字符串

func RelativePath

func RelativePath(name string) string

RelativePath 获取相对可执行文件的路径

func RemoveMinSuffix

func RemoveMinSuffix(path string) string

RemoveMinSuffix 去除第二段`min`后缀

func RemoveSlash

func RemoveSlash(path string) string

RemoveSlash 移除路径最后的`/`

func Replace

func Replace(table map[string]string, s string) string

Replace 根据替换表执行批量替换

func SliceDifference

func SliceDifference(slice1, slice2 []string) []string

SliceDifference 求两个切片差集

func SliceIntersect

func SliceIntersect(slice1, slice2 []string) []string

SliceIntersect 求两个切片交集

func SplitPath

func SplitPath(path string) []string

SplitPath 分割路径为列表

Types

type Logger

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

Logger 日志

var GloablLogger *Logger

func Log

func Log() *Logger

Log 返回日志对象

func (*Logger) Debug

func (ll *Logger) Debug(format string, v ...interface{})

Debug 校验

func (*Logger) Error

func (ll *Logger) Error(format string, v ...interface{})

Error 错误

func (*Logger) Info

func (ll *Logger) Info(format string, v ...interface{})

Info 信息

func (*Logger) Panic

func (ll *Logger) Panic(format string, v ...interface{})

Panic 极端错误

func (*Logger) Println

func (ll *Logger) Println(prefix string, msg string)

Println 打印

func (*Logger) Warning

func (ll *Logger) Warning(format string, v ...interface{})

Warning 警告

Jump to

Keyboard shortcuts

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