utils

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 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 added in v0.2.5

func CopyDir(dst, src string) error

func CopyFile added in v0.2.5

func CopyFile(dst, src string) error

func CurDir added in v0.2.5

func CurDir() string

func DiffFile added in v0.2.5

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 added in v0.2.5

func FileExists(filename string) bool

func FileOpen added in v0.2.5

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

func FileToUrlPath added in v0.2.5

func FileToUrlPath(file string) string

func ForceCreateFile added in v0.2.5

func ForceCreateFile(filename string) *os.File

func ForeachFile added in v0.2.5

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

func GetFileInfo added in v0.2.5

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

func GetFilelist added in v0.2.5

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

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

func GetStringValue added in v0.2.5

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

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

func GetlastModified added in v0.2.5

func GetlastModified(file string) time.Time

func HasChineseChar

func HasChineseChar(str string) bool

func IsFileSame added in v0.2.5

func IsFileSame(left, right string) bool

func Krand

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

Krand 随机字符串

func NoneError added in v0.2.5

func NoneError(err error)

func PathExists added in v0.2.5

func PathExists(path string) bool

func ReadExcelsheet2Slice added in v0.2.5

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

func ReadFileContext added in v0.2.5

func ReadFileContext(path string) string

func ReadJson2Slice added in v0.2.5

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

func ReadXml added in v0.2.5

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

func RemoveFile added in v0.2.5

func RemoveFile(file string)

func SHA1EncodeFileName added in v0.2.5

func SHA1EncodeFileName(filename string) string

func SaveFile added in v0.2.5

func SaveFile(file string, content string)

func SaveJson added in v0.2.5

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

func SaveUtf8BomFile added in v0.2.5

func SaveUtf8BomFile(file string, content string)

func SaveXml added in v0.2.5

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

func SetLastModified added in v0.2.5

func SetLastModified(file string, time time.Time)

func ShowError added in v0.2.5

func ShowError(err error) bool

func UNCPath added in v0.2.5

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 added in v0.2.5

func UrlToLocalFile(Url string) string

func WriteFile added in v0.2.5

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