gomini

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

README

gomini

go test
go test -v
./gomini.test -test.v
go test -v ./rand_test.go ./rand.go -bench=".*"
go clean -testcache

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WeekdayString = []string{"周日", "周一", "周二", "周三", "周四", "周五", "周六"}

Functions

func AddInt

func AddInt(s []int, a int) []int

func AddInt64

func AddInt64(s []int64, a int64) []int64

func CmdRunWithTimeout

func CmdRunWithTimeout(cmd *exec.Cmd, timeout time.Duration) (error, bool)

func ConvertBase64ToImage

func ConvertBase64ToImage(content string, imagePath, prefixURI string) (string, error)

转换base64为图片链接

func ConvertToLetter

func ConvertToLetter(iCol int) string

Excel 转化

func DelFile

func DelFile(files []os.FileInfo, count int, fileDir string)

如果文件达到最上限,按时间删除

func Exec

func Exec(bin string, args ...string) (string, error)

func ExecWithTimeout

func ExecWithTimeout(bin string, timeout time.Duration, args ...string) (string, error)

func FileGetContent

func FileGetContent(file string) (string, error)

get string from text file

func FileMTime

func FileMTime(file string) (int64, error)

get file modified time

func FilePutContent

func FilePutContent(file string, content string) (int, error)

put string to file

func FileSize

func FileSize(file string) (int64, error)

get file size as how many bytes

func GeoPositionToDistance

func GeoPositionToDistance(from, to GeoPosition) int

单位:米

func GetFloat64Str

func GetFloat64Str(f float64) string

func GetFloatStr

func GetFloatStr(f float64) string

func GetInt16Str

func GetInt16Str(d int16) string

func GetInt32Str

func GetInt32Str(d int32) string

func GetInt64Str

func GetInt64Str(d int64) string

func GetInt8Str

func GetInt8Str(d int8) string

func GetIntStr

func GetIntStr(d int) string

func GetIpMask

func GetIpMask(start, end string) string

如要将一B类IP地址为168.195.0.0的网络划分成若干子网,要求每个子网内有主机数为700台, 则该子网掩码的计算方法如下(也是对应以上各基本步骤): 第1步,首先将子网中要求容纳的主机数“700”转换成二进制,得到1010111100。 第2步,计算出该二进制的位数为10位,即n = 10 第3步,将255.255.255.255从后向前的10位全部置“0”,得到的二进制数为“11111111.11111111.11111100.00000000”, 转换成十进制后即为255.255.252.0,这就是该要划分成主机数为700的B类IP地址 168.195.0.0的子网掩码。

func GetRandomNumber

func GetRandomNumber(n int) string

随机码

func GetStrBool

func GetStrBool(strv string, def ...bool) (bool, error)

func GetStrFloat

func GetStrFloat(strv string, def ...float64) (float64, error)

func GetStrFloat64

func GetStrFloat64(strv string, def ...float64) (float64, error)

func GetStrInt

func GetStrInt(strv string, def ...int) (int, error)

func GetStrInt16

func GetStrInt16(strv string, def ...int16) (int16, error)

func GetStrInt32

func GetStrInt32(strv string, def ...int32) (int32, error)

func GetStrInt64

func GetStrInt64(strv string, def ...int64) (int64, error)

func GetStrInt8

func GetStrInt8(strv string, def ...int8) (int8, error)

func GetStrUint

func GetStrUint(strv string, def ...uint) (uint, error)

func GetStrUint16

func GetStrUint16(strv string, def ...uint16) (uint16, error)

func GetStrUint32

func GetStrUint32(strv string, def ...uint32) (uint32, error)

func GetStrUint64

func GetStrUint64(strv string, def ...uint64) (uint64, error)

func GetStrUint8

func GetStrUint8(strv string, def ...uint8) (uint8, error)

func GetTimeAgo

func GetTimeAgo(t int64) (s string)

func GetUint16Str

func GetUint16Str(d uint16) string

func GetUint32Str

func GetUint32Str(d uint32) string

func GetUint64Str

func GetUint64Str(d uint64) string

func GetUint8Str

func GetUint8Str(d uint8) string

func GetUintStr

func GetUintStr(d uint) string

func GetWeekdayCnName

func GetWeekdayCnName(layout string, value string) (int, string, error)

获取周一到周日

func InSlice

func InSlice(s []string, a string) bool

func Int64sToInterfaces added in v1.3.0

func Int64sToInterfaces(s []int64) (i []interface{})

func IntsToInt64s added in v1.3.0

func IntsToInt64s(s []int) (i []int64)

func IntsToInterfaces added in v1.3.0

func IntsToInterfaces(s []int) (i []interface{})

func Ip2long

func Ip2long(ipstr string) (ip uint32)

func IsExist

func IsExist(path string) bool

IsExist returns whether a file or directory exists.

func IsFile

func IsFile(file string) bool

it returns false when it's a directory or does not exist.

func IsImage

func IsImage(extName string) bool

检查文件扩展名是否是图片

func IsPrivateIP

func IsPrivateIP(ip string) bool

判断IP地址是否为预留ip

func Long2ip

func Long2ip(ip uint32) string

func Mkdir

func Mkdir(src string) error

create dir

func RandomCreateBytes

func RandomCreateBytes(n int, alphabets ...byte) []byte

RandomCreateBytes generate random []byte by specify chars.

func Remove

func Remove(file string) error

delete file

func RemoveAll

func RemoveAll(path string) error

RemoveAll删除path指定的文件,或目录及它包含的任何下级对象。它会尝试删除所有东西,除非遇到错误并返回。 如果path指定的对象不存在,RemoveAll会返回nil而不返回错误。

func Rename

func Rename(file string, to string) error

rename file name

func Repeat

func Repeat(s string, count int, sep ...string) string

Repeat("?",10,",") ?,?,?,?,?,?,?,?,?,?

func StringsToInterfaces added in v1.3.0

func StringsToInterfaces(s []string) (i []interface{})

func Substr

func Substr(s string, start, length int) string

字符串截取

func Union

func Union(s []string, a []string) []string

func Uniq

func Uniq(s []string) (r []string)

func WebTime

func WebTime(t time.Time) string

Types

type FileRepos

type FileRepos []Repository

func (FileRepos) Len

func (r FileRepos) Len() int

func (FileRepos) Less

func (r FileRepos) Less(i, j int) bool

func (FileRepos) Swap

func (r FileRepos) Swap(i, j int)

type GeoPosition

type GeoPosition struct {
	// Longitude 经度
	Longitude float64
	// Latitude 纬度
	Latitude float64
}

type IpNetmask

type IpNetmask struct {
	Ipaddr    string //IP地址
	Mask      string //IP掩码
	Subnet    string //网络地址
	Broadcast string //广播地址
	IpStart   string //起始IP
	IpEnd     string //结束IP
}

func GetIpAddrs

func GetIpAddrs(ipaddr, mask string, ok bool) (ipNetmask *IpNetmask, ipRangeAddrs []string)

type Mail

type Mail struct {
	// contains filtered or unexported fields
}

func NewMail

func NewMail(host string, port int, username, password string, num ...int64) *Mail

func (*Mail) SendEmailDaemon

func (m *Mail) SendEmailDaemon()

func (*Mail) SendEmailOnce

func (m *Mail) SendEmailOnce() error

func (*Mail) SetMessage

func (m *Mail) SetMessage(params map[string]interface{})

type Repository

type Repository struct {
	Name     string
	FileTime int64
}

Directories

Path Synopsis
aes.go des.go md5.go padding.go rsa.go sha1.go
aes.go des.go md5.go padding.go rsa.go sha1.go

Jump to

Keyboard shortcuts

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