utils

package
v0.2.35 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KC_RAND_KIND_NUM   = 0 // 纯数字
	KC_RAND_KIND_LOWER = 1 // 小写字母
	KC_RAND_KIND_UPPER = 2 // 大写字母
	KC_RAND_KIND_ALL   = 3 // 数字、大小写字母
)
View Source
const (
	EXT_HTML = ".html"
	EXT_XML  = ".xml"
	EXT_JSON = ".json"
	EXT_ZIP  = ".zip"
	EXT_IDOC = ".idoc"
	EXT_ZED  = ".zed"
	EXT_PDF  = ".pdf"
)

Variables

This section is empty.

Functions

func Checkerr

func Checkerr(err error, msg string)

func Checkerr2

func Checkerr2(err error, msg string) (shouldExit bool)

func CopyDir

func CopyDir(dst, src string) error

func CopyFile

func CopyFile(dst, src string) error

func CurDir

func CurDir() string

func DiffFile

func DiffFile(left, right string) (diff string, same bool, err error)

func EscapeSpecificChar

func EscapeSpecificChar(str string) string

func EscapeString

func EscapeString(driverName, str string) string

func EscapeValuesString

func EscapeValuesString(driverName, str string) string

func FetchRow

func FetchRow(db *sql.DB, sqlstr string, args ...interface{}) (*map[string]string, error)

func FileExists

func FileExists(filename string) bool

func FileOpen

func FileOpen(file_name string) ([]byte, error)

func FileToUrlPath

func FileToUrlPath(file string) string

func ForceCreateFile

func ForceCreateFile(filename string) *os.File

func ForeachFile

func ForeachFile(path string, pattern string, onFindFile func(fileName string) error) error

func GetFileInfo

func GetFileInfo(filename string) (name, ext string, en bool)

func GetFilelist

func GetFilelist(path string, pattern string) []string

golang 文件处理公共函数库 https://www.cnblogs.com/chengbiwei/p/9672896.html

func GetStringValue

func GetStringValue(i interface{}) (result string)

使用Value.Kind()类型判断,并获取真实值进行打印

func GetlastModified

func GetlastModified(file string) time.Time

func HasChineseChar

func HasChineseChar(str string) bool

func IsFileSame

func IsFileSame(left, right string) bool

func Krand

func Krand(size int, kind int) []byte

Krand 随机字符串

func NoneError

func NoneError(err error)

func PathExists

func PathExists(path string) bool

func ReadExcelsheet2Slice

func ReadExcelsheet2Slice(sheet *xlsx.Sheet, dataStartRow int) (records []map[string]interface{}, err error)

func ReadFileContext

func ReadFileContext(path string) string

func ReadJson2Slice

func ReadJson2Slice(filename string) (records []map[string]interface{}, err error)

func ReadXml

func ReadXml(obj interface{}, filename string) error

func RemoveFile

func RemoveFile(file string)

func SHA1EncodeFileName

func SHA1EncodeFileName(filename string) string

func SaveFile

func SaveFile(file string, content string)

func SaveJson

func SaveJson(filename string, obj interface{}) error

func SaveUtf8BomFile

func SaveUtf8BomFile(file string, content string)

func SaveXml

func SaveXml(filename string, obj interface{}) error

func SetLastModified

func SetLastModified(file string, time time.Time)

func ShowError

func ShowError(err error) bool

func UNCPath

func UNCPath(s string) string

UNCPath converts an absolute Windows path to a UNC long path. https://blog.klauspost.com/long-windows-paths-unc-paths-in-go/ \\?\UNC\server\share\dir\file.txt

func UrlToLocalFile

func UrlToLocalFile(Url string) string

func WriteFile

func WriteFile(file string, data []byte)

Types

This section is empty.

Jump to

Keyboard shortcuts

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