util

package
v0.0.0-...-9a5be64 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YYYYMMDDHHMMSS = "20060102150405"
	DateOnly       = "2006-01-02"
	TimeOnly       = "15:04:05"
	DateTime       = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(path string) error

func DelFile

func DelFile(path string)

DelFile 删除文件

func FileIsExist

func FileIsExist(path string) bool

FileIsExist 判断文件是否存在

func FileIsNotExist

func FileIsNotExist(path string) bool

FileIsNotExist 判断文件是否不存在

func FolderIsExist

func FolderIsExist(path string) bool

FolderIsExist 判断目录是否存在

func FolderIsNotExist

func FolderIsNotExist(path string) bool

FolderIsNotExist 判断目录是否不存在

func GetFilesByRoot

func GetFilesByRoot(root string) ([]string, error)

GetFilesByRoot 获取指定目录下的所有文件

func GetParamMap

func GetParamMap(url string, params map[string]string, header map[string]string) ([]byte, error)

func HasPerm

func HasPerm(path string, perm os.FileMode)

HasPerm 判断文件是否有权限

func MapToJsonFormatString

func MapToJsonFormatString(i map[string]interface{}) (string, error)

MapToJsonFormatString Map转换成Json格式的字符串

func MapToJsonStr

func MapToJsonStr(i map[string]interface{}) string

MapToJsonStr 将Map转换成Json字符串,没有换行等格式化

func Post

func Post(url string, params map[string]string, header map[string]string) ([]byte, error)

func PrintMapJsonStr

func PrintMapJsonStr(i map[string]interface{})

PrintMapJsonStr 将Map按照Json格式输出

func ReadCSVFlatMap

func ReadCSVFlatMap[R any](filepath string, mapFn func([]string, int) []R) ([]R, error)

ReadCSVFlatMap 读取CSV文件,将处理函数中返回的数组扁平化处理

func ReadCSVMap

func ReadCSVMap[R any](filepath string, mapFn func([]string, int) R) ([]R, error)

ReadCSVMap 读取CSV文件,并调用处理函数,将结果置换成结构体

func SimpleGet

func SimpleGet(url string, header map[string]string) ([]byte, error)

func SimpleReadCSV

func SimpleReadCSV(filepath string) ([][]string, error)

SimpleReadCSV 基础读取CSV文件

func SimpleWriteCSV

func SimpleWriteCSV(filepath string, data [][]string) error

func StrToStruct

func StrToStruct[T any](str string) (T, error)

func StrToStructArr

func StrToStructArr[T any](str string) ([]T, error)

func StrToTime

func StrToTime(timeStr, formatStr string) (time.Time, error)

StrToTime 字符串转日期

func StringIsEmpty

func StringIsEmpty(str string) bool

func StringIsNotEmpty

func StringIsNotEmpty(str string) bool

func TimeToStr

func TimeToStr(t time.Time, format string) string

func WriteCSVMap

func WriteCSVMap[T any](filepath string, data []T, mapFn func(t T, i int) []string) error

WriteCSVMap 将指定数据写入文件中,可自定义结构体的转换

Types

This section is empty.

Jump to

Keyboard shortcuts

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