tools

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//定义Format 日期显示
	FormatDay = "2006-01-02"
	//定义Format 日期时分秒显示
	FormatDayHourMinSecond = "2006-01-02 15:04:05"
)

时间常量

Variables

This section is empty.

Functions

func Bytes2str

func Bytes2str(b []byte) string

func BytesToInt64

func BytesToInt64(buf []byte) int64

byte 转 int64

func Catch

func Catch(err error)

捕获异常 error

func Cmdexec

func Cmdexec(cmd string) string

Cmdexec 执行系统命令

func DisplaySize

func DisplaySize(raw float64) string

返回传入值具体大小

func DuplicateIntArray

func DuplicateIntArray(m []int) []int

数组去重

func DuplicateStringArray

func DuplicateStringArray(m []string) []string

字符串数组去重

func ExistIntArray

func ExistIntArray(s []int, e int) bool

数组存在某个数字

func ExistStringArray

func ExistStringArray(s []string, e string) bool

字符串数组存在某个字符串

func FloatRound

func FloatRound(f float64, n int) float64

截取小数位数

func FormatFileSize

func FormatFileSize(fileSize int64) (size string)

FormatFileSize 字节的单位转换 保留两位小数

func GetDifferentIntArray

func GetDifferentIntArray(sourceList, sourceList2 []int) (result []int)

数组取出不同元素 放入结果 sourceList中的元素不在sourceList2中 则取到result中

func GetDifferentStringArray

func GetDifferentStringArray(sourceList, sourceList2 []string) (result []string)

数组取出不同元素 放入结果 sourceList中的元素不在sourceList2中 则取到result中

func GetStrLine

func GetStrLine(file, str string) ([]string, error)

获取字符串在文件内容

func Int64ToBytes

func Int64ToBytes(i int64) []byte

int64 转 byte

func IntToInt64

func IntToInt64(value int) int64

int 转 int64

func IsDir

func IsDir(fileAddr string) bool

IsDir 判断目录是否存在

func ParseMorningTime

func ParseMorningTime(t time.Time) time.Time

返回某一天的当地时区0点

func ReadConfigIni

func ReadConfigIni(key, value string) (result string)

读取configIni文件内容

func RemoveDuplicates

func RemoveDuplicates(a []string) (ret []string)

RemoveDuplicates 去除重复字符串和空格

func RemoveElement

func RemoveElement(slice []interface{}, elem interface{}) []interface{}

func ResolveTime

func ResolveTime(seconds uint64) string

时间转换函数

func ScanDirBySuffix

func ScanDirBySuffix(dirName, suffix string) []string

ScanDirBySuffix 扫描当前目录下文件,不递归扫描,指定后缀

func SetCommandStd

func SetCommandStd(cmd *exec.Cmd) (stdout, stderr *bytes.Buffer)

SetCommandStd cmd Grep

func SingleSlashToDoubleSlash

func SingleSlashToDoubleSlash(path string) string

SingleSlashToDoubleSlash 把系统获取的路径/ 转换为//格式

func Str2bytes

func Str2bytes(s string) []byte

func StringToInt

func StringToInt(value string) (i int)

string 转 int

func TimeToString

func TimeToString(time time.Time) string

Time 转 String

func TimeToStringDay

func TimeToStringDay(time time.Time) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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