utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirectory

func CreateDirectory(path string) error

CreateDirectory checks if a directory exists, and creates it if it doesn't

func CreatePIDFile

func CreatePIDFile(pidFilePath string) error

CreatePIDFile creates and locks a PID file to prevent multiple instances.

func DetectMimeType

func DetectMimeType(path string) string

DetectMimeType tries to determine the MIME type of a file

func IsImageFile

func IsImageFile(mimeType string) bool

IsImageFile determines if a file is an image based on MIME type

func IsTextFile

func IsTextFile(mimeType string) bool

IsTextFile determines if a file is likely a text file based on MIME type

func MergeJSONToStruct

func MergeJSONToStruct(target any, jsonMap map[string]any) error

MergeJSONToStruct 将JSON中的字段合并到结构体中

func PathToResourceURI

func PathToResourceURI(path string) string

PathToResourceURI converts a file path to a resource URI

func RemovePIDFile

func RemovePIDFile(pidFilePath string) error

RemovePIDFile releases the lock and removes the PID file.

func StringInSlice

func StringInSlice(s string, modules []string) bool

StringInSlice checks if a string is in a slice of strings

Types

type RotateWriter

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

RotateWriter 是一个简单的日志轮转写入器

func NewRotateWriter

func NewRotateWriter(filePath string, maxSize int64) (*RotateWriter, error)

NewRotateWriter 创建一个新的 RotateWriter 实例

func (*RotateWriter) CheckFileSize

func (rw *RotateWriter) CheckFileSize() error

CheckFileSize 检查当前文件大小

func (*RotateWriter) Close

func (rw *RotateWriter) Close() error

Close 关闭 RotateWriter

func (*RotateWriter) Write

func (rw *RotateWriter) Write(p []byte) (n int, err error)

Write 实现 io.Writer 接口

Jump to

Keyboard shortcuts

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