goutils

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

README

utils

工具库

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNotExist

func CheckNotExist(src string) bool

CheckNotExist check if the file exists

func CheckPermission

func CheckPermission(src string) bool

CheckPermission check if the file has permission

func Contains

func Contains(arrayOrMap interface{}, val interface{}) (isExist bool)

Contains 判断切片中是否包含某元素

func CreateRandomNumber

func CreateRandomNumber(len int) string

CreateRandomNumber 获取指定位数的随机数

func CreateRandomString

func CreateRandomString(len int) string

CreateRandomString 随机字符串

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 md5 encryption

func FileExists

func FileExists(path string) (bool, error)

FileExists 判断文件是否存在

func GetDiffElement

func GetDiffElement(arr1, arr2 []string) []string

GetDiffElement 计算两个数组或者切片的差集

func GetExt

func GetExt(fileName string) string

GetExt get the file ext

func GetIPRange

func GetIPRange(ipRange, splitStr string) (ipStart, ipEnd string)

GetIPRange 得到ip范围 比如192.168.1.1-254

func GetSize

func GetSize(f multipart.File) (int, error)

GetSize get the file size

func IP2long

func IP2long(ipstr string) uint32

IP2long 字符串IP转化为long IP

func InIPRange

func InIPRange(ip string, ipRange string, isEqual bool) (inRange bool)

InIPRange 判断某个ip是否在某个ip范围内 比如192.168.1.5 在 192.168.1.5-192.168.1.254段内

func IsInSameSection

func IsInSameSection(IP1, IP2, mask string) bool

IsInSameSection 判断两个ip是否在同一个网段

func IsNotExistMkDir

func IsNotExistMkDir(src string) error

IsNotExistMkDir create a directory if it does not exist

func Long2IP

func Long2IP(ipLong uint32) string

Long2IP long IP转化为字符串

func Md5Check

func Md5Check(content, encrypted string) bool

Md5Check 验证一个文本MD5的值是否和指定值相同

func Md5SumFile

func Md5SumFile(file string) (value [md5.Size]byte, err error)

Md5SumFile 得到文件的md5值

func MkDir

func MkDir(src string) error

MkDir create a directory

func MustOpen

func MustOpen(fileName, filePath string) (*os.File, error)

MustOpen maximize trying to open the file

func Open

func Open(name string, flag int, perm os.FileMode) (*os.File, error)

Open a file according to a specific mode

func RemoveFile

func RemoveFile(fileName string) error

RemoveFile 删除文件

func Round

func Round(number float64, decimal uint8) float64

Round 四舍五入

func StringArray2Int

func StringArray2Int(data []string) []int

StringArray2Int 将字符串数组转化为整形数组

func Substr

func Substr(str string, start int, end int) string

Substr 截取字符串 start 起点下标 end 终点下标(不包括)

func TimeFormat

func TimeFormat(oldLayout, newLayout, oldTimeStr string) (string, error)

TimeFormat 转换时间格式

func TimeToTimestamp

func TimeToTimestamp(layout, timestr string) (int64, error)

TimeToTimestamp 将日期时间格式转换为时间戳

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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