Documentation ¶
Index ¶
- Constants
- Variables
- func AppendOrCreateFile(filePath string, content []byte) error
- func ConvertFileSizeMB(size int64) float64
- func CreateAndOpenFile(filePath string) (file *os.File, err error)
- func DetectTypeByBytes(bytes []byte) string
- func DetectTypeByFile[T *os.File | *multipart.FileHeader](file T) string
- func DirTree(dir string, result *[]FileNode) error
- func ScanCodeToTxT(absPath string, ext string)
- func Tail(filename string, n uint64) (buff []string, err error)
- type FileNode
- type FileSize
- type FileType
Constants ¶
View Source
const (
TypeImage = 1
)
Variables ¶
View Source
var ( Jpeg = FileType{ ContentType: "image/jpeg", Suffix: ".jpg", } Avif = FileType{ ContentType: "image/avif", Suffix: ".avif", } Gif = FileType{ ContentType: "image/gif", Suffix: ".gif", } Png = FileType{ ContentType: "image/png", Suffix: ".png", } Heic = FileType{ ContentType: "image/heic", Suffix: ".heic", } )
Functions ¶
func AppendOrCreateFile ¶
AppendOrCreateFile 函数接受文件路径和要追加的内容作为参数 如果文件存在,则追加内容 如果文件不存在,则创建文件并写入内容 如果文件所在目录不存在,则先创建目录
func CreateAndOpenFile ¶
CreateAndOpenFile 创建文件并以追加的方式打开文件
func DetectTypeByFile ¶
func DetectTypeByFile[T *os.File | *multipart.FileHeader](file T) string
DetectTypeByFile 通过文件头判断图片类型 支持os.File和multipart.FileHeader 二选一
func ScanCodeToTxT ¶
ScanCodeToTxT 扫描文件夹下的所有文件,并导出到output.txt文件中 ext 文件后缀 .go .dart
Types ¶
Click to show internal directories.
Click to hide internal directories.