utils

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BASE_64_TABLE = "1234567890poiuytreqwasdfghjklmnbvcxzQWERTYUIOPLKJHGFDSAZXCVBNM-_"
)

Variables

View Source
var Array = NewArray()

Functions

func Dial

func Dial(addr string) (*smtp.Client, error)

return a smtp client

func NewArray

func NewArray() *array

func SendMailUsingTLS

func SendMailUsingTLS(addr string, auth smtp.Auth, from string,
	to []string, msg []byte) (err error)

Types

type Codec

type Codec struct {
}

func NewCodec

func NewCodec() *Codec

func (*Codec) DecodePack

func (c *Codec) DecodePack(read io.Reader) (string, error)

func (*Codec) EncodePack

func (c *Codec) EncodePack(message []byte) ([]byte, error)

type Convert

type Convert struct{}

func NewConvert

func NewConvert() *Convert

func (*Convert) BoolToInt

func (convert *Convert) BoolToInt(boolValue bool) int

bool 转化为 int

func (*Convert) BoolToString

func (convert *Convert) BoolToString(boolValue bool) string

bool 转化为字符串

func (*Convert) FloatToString

func (convert *Convert) FloatToString(f float64, fmt byte, prec, bitSize int) string

float 转化为字符串

func (*Convert) IntToBool

func (convert *Convert) IntToBool(number int) bool

int 转化为 bool

func (*Convert) IntToString

func (convert *Convert) IntToString(number int64, base int) string

int 转化为字符串 base 范围 2-32 进制

func (*Convert) IntToTenString

func (convert *Convert) IntToTenString(number int) string

int 转化为10进制字符串 IntToString(number, 10)

func (*Convert) StringToInt

func (convert *Convert) StringToInt(str string) int

string to int(10进制)

func (*Convert) StringToInt64

func (convert *Convert) StringToInt64(str string) int64

string to int64(10进制)

func (*Convert) ToInt64

func (convert *Convert) ToInt64(value interface{}) (d int64, err error)

转化任何的数为 int64

type Date

type Date struct{}

func NewDate

func NewDate() *Date

func (*Date) Format

func (date *Date) Format(unixTime interface{}, format string) string

格式化 unix 时间戳

type Email

type Email struct {
}

func NewEmail

func NewEmail() *Email

func (*Email) SendEmail

func (email *Email) SendEmail(emailParam map[string]string, content, contentType, subject string) (err error)

*

  • 发送邮件
  • @param emailParam 邮件参数
  • @param content 邮件内容
  • @param contentType 内容类型(可为html或plain)
  • @param subject 邮件标题

type Encrypt

type Encrypt struct{}

func NewEncrypt

func NewEncrypt() *Encrypt

func (*Encrypt) Base64Decode

func (encrypt *Encrypt) Base64Decode(str string) (string, error)

base64 解密

func (*Encrypt) Base64DecodeBytes

func (encrypt *Encrypt) Base64DecodeBytes(str string) ([]byte, error)

base64 解密

func (*Encrypt) Base64Encode

func (encrypt *Encrypt) Base64Encode(str string) string

base64 加密

func (*Encrypt) Base64EncodeBytes

func (encrypt *Encrypt) Base64EncodeBytes(bytes []byte) []byte

base64 加密

func (*Encrypt) Md5Encode

func (encrypt *Encrypt) Md5Encode(str string) string

md5加密

type File

type File struct {
}

func NewFile

func NewFile() *File

func (*File) GetFileContents

func (f *File) GetFileContents(filePath string) (content string, err error)

get file contents

func (*File) IsReadable

func (f *File) IsReadable(filename string) error

is read permission

func (*File) IsWritable

func (f *File) IsWritable(filename string) error

is write permission

func (*File) IsWriterReadable

func (f *File) IsWriterReadable(file string) error

is read and write permission

func (*File) PathIsEmpty

func (f *File) PathIsEmpty(path string) bool

path is empty

func (*File) PathIsExists

func (f *File) PathIsExists(path string) (bool, error)

file or path is exists

type Misc

type Misc struct{}

func NewMisc

func NewMisc() *Misc

func (*Misc) GetLocalIp

func (m *Misc) GetLocalIp() string

get local ip

func (*Misc) GetMapDefault

func (m *Misc) GetMapDefault(mapValue map[string]interface{}, key string, def interface{}) interface{}

get map default

func (*Misc) Page

func (m *Misc) Page(total, page, pagesize int, url string, args ...interface{}) string

分页方法 total: 一共多少记录 page: 当前是第几页 pagesize: 每页多少 url: url里面的{page}会被替换成页码 args:

order 分页条的组成,是一个数组,可以按着1-6的序号,选择分页条组成部分和每个部分的顺序
a_count   分页条中a页码链接的总数量,不包含当前页的a标签,默认10个。

func (*Misc) RandInt

func (m *Misc) RandInt(strLen int) string

rand int

func (*Misc) RandString

func (m *Misc) RandString(strlen int) string

rand string

type Paginator

type Paginator struct {
	Request     *http.Request
	PerPageNums int
	MaxPages    int
	// contains filtered or unexported fields
}

func NewPaginator

func NewPaginator(req *http.Request, per int, nums interface{}) *Paginator

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

func (*Paginator) HasPages

func (p *Paginator) HasPages() bool

func (*Paginator) HasPrev

func (p *Paginator) HasPrev() bool

func (*Paginator) IsActive

func (p *Paginator) IsActive(page int) bool

func (*Paginator) Nums

func (p *Paginator) Nums() int64

func (*Paginator) Offset

func (p *Paginator) Offset() int

func (*Paginator) Page

func (p *Paginator) Page() int
func (p *Paginator) PageLink(page int) string

func (*Paginator) PageLinkFirst

func (p *Paginator) PageLinkFirst() (link string)

func (*Paginator) PageLinkLast

func (p *Paginator) PageLinkLast() (link string)

func (*Paginator) PageLinkNext

func (p *Paginator) PageLinkNext() (link string)

func (*Paginator) PageLinkPrev

func (p *Paginator) PageLinkPrev() (link string)

func (*Paginator) PageNums

func (p *Paginator) PageNums() int

func (*Paginator) Pages

func (p *Paginator) Pages() []int

func (*Paginator) SetNums

func (p *Paginator) SetNums(nums interface{})

type Request

type Request struct {
}

func NewRequest

func NewRequest() *Request

func (*Request) Get

func (utils *Request) Get(queryUrl string, queryValues map[string]string, headerValues map[string]string) (body string, code int, err error)

http get request

func (*Request) HttpPost

func (utils *Request) HttpPost(queryUrl string, queryValues map[string]string, headerValues map[string]string) (body string, code int, err error)

http post request

func (*Request) ParseString

func (utils *Request) ParseString(params string) map[string]string

parse params(name=nick&pass=123)

func (*Request) QueryBuilder

func (utils *Request) QueryBuilder(queryUrl string, queryValues map[string]string) string

build query params

type System

type System struct {
}

func (*System) GetCpu

func (s *System) GetCpu()

Jump to

Keyboard shortcuts

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