osHelper

package
v1.5.13 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDir added in v1.5.6

func CreateDir(dirName string, perm os.FileMode) error

CreateDir 创建文件夹 perm:755,777

func CreateIfNotExist added in v1.5.6

func CreateIfNotExist(dirName string, perm os.FileMode) (err error)

CreateIfNotExist 如果目录不存在,则创建

func Delete added in v1.5.6

func Delete(filePath string) error

Delete 删除指定路径文件夹/文件

func DeleteFiles added in v1.5.6

func DeleteFiles(filePaths []string) (err error)

DeleteFiles 删除指定路径文件夹/文件

func DownloadFile

func DownloadFile(url string, localPath string, fb func(length, downLen int64)) error

DownloadFile 从url中下载文件

func DownloadFileFromContext added in v1.5.6

func DownloadFileFromContext(r *http.Request, fieldName, targetPath string) (fileName, filePath string, err error)

DownloadFileFromContext 从请求体中保存文件

func ExistSameNameFile added in v1.5.6

func ExistSameNameFile(filename string) bool

ExistSameNameFile 判断是否已存在同名文件

func ExistSameSizeFile added in v1.5.6

func ExistSameSizeFile(filename string, filesize int64) bool

*

  • @func: ExistFile 判断文件是否已存在
  • @author Wiidz
  • @date 2019-11-16

func GetFileBuf

func GetFileBuf(uri string) []byte

func GetFileNameFromLocalPath added in v1.5.6

func GetFileNameFromLocalPath(localFilePath string) (targetDir, wholeName, fileName, fileType string)

GetFileNameFromLocalPath 从本地路径中提取文件 localFilePath 应该是 /home/www/wwwroot/aaaaa.html 这样

func GetFileString added in v1.5.6

func GetFileString(uri string) string

func IsDirExist added in v1.5.6

func IsDirExist(dirPath string) bool

IsDirExist 判断目录是否存在 dirPath 绝对路径,不要以/结尾

func ReadByteFromFile added in v1.5.6

func ReadByteFromFile(filePath string) (byteData []byte, err error)

ReadByteFromFile 从文件中读取byte数据

func ReadJsonFile

func ReadJsonFile(filePath string, targetStruct interface{}) error

ReadJsonFile 读取json格式的文件

func ReadJsonFileMap added in v1.5.6

func ReadJsonFileMap(filePath string) map[string]interface{}

ReadJsonFileMap 读取json格式的文件

func SaveStringToFile added in v1.5.6

func SaveStringToFile(content string, filename string) error

SaveStringToFile 将字符串输出到文件中

func SimpleDownloadFile added in v1.5.6

func SimpleDownloadFile(url string) (finalFilePath string, err error)

SimpleDownloadFile 简单下载(下载到当前工程目录的/tmp下,记得给权限)

Types

This section is empty.

Jump to

Keyboard shortcuts

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