utils

package
v0.0.0-...-c285f8c Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserID = iota // 用户
)

ID类型

Variables

View Source
var DefaultLog = NewLog(logrus.DebugLevel, "vinki.log")
View Source
var (
	// ErrTypeNotMatch ID类型不匹配
	ErrTypeNotMatch = errors.New("ID类型不匹配")
)

Functions

func ExistsDir

func ExistsDir(path string) bool

ExistsDir 判断是否存在该目录

func ExistsFile

func ExistsFile(path string) bool

ExistsFile 判断是否存在该文件

func ExistsPath

func ExistsPath(path string) bool

ExistsPath 判断所给路径是否存在

func GenerateHash

func GenerateHash(id uint64, pkType int, salt string) string

GenerateHash 计算数据库内主键对应的HashID

func GetOriginID

func GetOriginID(hashString string, pkType int, salt string) (uint, error)

GetOriginID 计算HashID对应的数据库ID

func HashDecode

func HashDecode(hashString string, salt string) ([]int, error)

HashDecode 对给定数据计算原始数据

func HashEncode

func HashEncode(values []int, salt string) (string, error)

HashEncode 对给定数据计算HashID

func IsDir

func IsDir(path string) bool

IsDir 判断路径是否是目录

func IsDirectoryInList

func IsDirectoryInList(directory string, list []string) bool

IsDirectoryInList 判断目录是否在列表中

func IsFile

func IsFile(path string) bool

IsFile 判断路径是否是文件

func IsInList

func IsInList(list []string, target string) bool

IsInList 判断项目是否在列表内

func Log

func Log() *logrus.Logger

func NewLog

func NewLog(level logrus.Level, outputFile string) *logrus.Logger

func PrettyPrint

func PrettyPrint(i interface{})

PrettyPrint 以 JSON 格式打印对象结构

func RandString

func RandString(n int) string

RandString 随机长度字符串

func RelativePath

func RelativePath(name string) string

获取运行环境的相对路径

func RenderMarkdown

func RenderMarkdown(mdPath string) ([]byte, error)

MarkdownFile2Html 读取本地 Markdown 文件并渲染为 Html bytes

func SplitIDs

func SplitIDs(s string) []uint64

splitIDs 将 ID 列表字符串转换为数值列表

Types

type FileInfo

type FileInfo struct {
	BriefName string
	Path      string
}

FileInfo 文件信息

func (*FileInfo) String

func (fi *FileInfo) String() string

type LogrusFileHook

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

func NewLogrusFileHook

func NewLogrusFileHook(file string, flag int, chmod os.FileMode) (*LogrusFileHook, error)

func (*LogrusFileHook) Fire

func (hook *LogrusFileHook) Fire(entry *logrus.Entry) error

Fire event

func (*LogrusFileHook) Levels

func (hook *LogrusFileHook) Levels() []logrus.Level

type TagPath2FileInfo

type TagPath2FileInfo map[string][]*FileInfo

Tag path 到 FileInfo 的映射,用于创建文档

func (TagPath2FileInfo) String

func (m TagPath2FileInfo) String() string

Jump to

Keyboard shortcuts

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