utils

package
v0.0.0-...-24ca73d Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2016 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src string) string

base64解密

func Base64Encode

func Base64Encode(src []byte) string

base64加密 例如:str := utils.Base64Encode([]byte("Hello, playground"))

func Crop

func Crop(old_img string, new_img string, img_size string) bool

ImageMagick之图片裁剪 http://www.netingcn.com/imagemagick-crop.html

func DecodeSegment

func DecodeSegment(where string) map[string]interface{}

将编码的搜索条件,解码成搜索条件Map数组 where 搜索条件的编码字符串

func Display

func Display(data ...interface{})

print the data in console

func EncodeSegment

func EncodeSegment(where map[string]interface{}) string

将搜索条件数组编码成一个字符串 where 搜索条件Map 例如:map转换成格式 name:张三|age:20 然后Base64

func FileSize

func FileSize(size int) string

文件大小

func GetClientIP

func GetClientIP() string

获取客户端IP

func GetDisplayString

func GetDisplayString(data ...interface{}) string

return data print string

func GetIpAddress

func GetIpAddress(ip string) map[string]interface{}

获取Ip地址详细信息

func GetServerIP

func GetServerIP() string

获取服务器IP

func GetSession

func GetSession(key string, session revel.Session) string

func Html2str

func Html2str(html string) string

Html过滤

func InSlice

func InSlice(v string, sl []string) bool

InSlice checks given string in string slice or not.

func InSliceIface

func InSliceIface(v interface{}, sl []interface{}) bool

InSliceIface checks given interface in interface slice.

func IsDir

func IsDir(path string) bool

是否目录

func IsEmail

func IsEmail(email string) bool

是否是email

func IsFile

func IsFile(path string) bool

是否文件

func IsMap

func IsMap(v interface{}) bool

是否Map类型

func Md5

func Md5(s string) string

返回MD5加密

func Negate

func Negate(old_img string, new_img string) bool

imagemagick图片反色处理 http://www.netingcn.com/imagemagick-negate.html

func RandomInt

func RandomInt(min int, max int) int

生成随机数字

func RandomString

func RandomString(num int) string

生成随机字符串

func Resize

func Resize(old_img string, new_img string, img_size string, output_align string, background string) bool

ImageMagick之图片缩放 http://www.netingcn.com/imagemagick-resize.html http://www.imagemagick.org/script/command-line-options.php#thumbnail 参数说明: old_img:原始图片 new_img:新图片 img_size:图片大小 output_align:位置center background:颜色

func SliceChunk

func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{})

SliceChuck separates one slice to some sized slice.

func SliceDiff

func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})

SliceDiff returns diff slice of slice1 - slice2.

func SliceFilter

func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{})

SliceFilter generates a new slice after filter function.

func SliceIntersect

func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})

SliceIntersect returns diff slice of slice1 - slice2.

func SliceMerge

func SliceMerge(slice1, slice2 []interface{}) (c []interface{})

SliceMerge merges interface slices to one slice.

func SlicePad

func SlicePad(slice []interface{}, size int, val interface{}) []interface{}

SlicePad prepends size number of val into slice.

func SliceRand

func SliceRand(a []interface{}) (b interface{})

SliceRand returns random one from slice.

func SliceRandList

func SliceRandList(min, max int) []int

SliceRandList generate an int slice from min to max.

func SliceRange

func SliceRange(start, end, step int64) (intslice []int64)

SliceRange generates a new slice from begin to end with step duration of int64 number.

func SliceReduce

func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{})

SliceReduce generates a new slice after parsing every value by reduce function

func SliceShuffle

func SliceShuffle(slice []interface{}) []interface{}

SliceShuffle shuffles a slice.

func SliceSum

func SliceSum(intslice []int64) (sum int64)

SliceSum sums all values in int64 slice.

func SliceUnique

func SliceUnique(slice []interface{}) (uniqueslice []interface{})

SliceUnique cleans repeated values in slice.

func Substr

func Substr(str string, length int64) string

按字节截取字符串 utf-8不乱码

func Vignette

func Vignette(old_img string, new_img string, img_size string) bool

生成圆角图片 img_size:0x4 background: none

func WatermarkLogo(old_img string, new_img string, logo_img string) bool

ImageMagicK给图片加水印之图片水印处理 http://www.netingcn.com/imagemagick-mark.html

func WatermarkText

func WatermarkText(old_img string, new_img string) bool

ImageMagicK给图片加水印之文字水印处理

Types

type Attachment

type Attachment struct {
	Filename string
	Header   textproto.MIMEHeader
	Content  []byte
}

Attachment is a struct representing an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question

type BeeMap

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

func NewBeeMap

func NewBeeMap() *BeeMap

NewBeeMap return new safemap

func (*BeeMap) Check

func (m *BeeMap) Check(k interface{}) bool

Returns true if k is exist in the map.

func (*BeeMap) Delete

func (m *BeeMap) Delete(k interface{})

Delete the given key and value.

func (*BeeMap) Get

func (m *BeeMap) Get(k interface{}) interface{}

Get from maps return the k's value

func (*BeeMap) Items

func (m *BeeMap) Items() map[interface{}]interface{}

Items returns all items in safemap.

func (*BeeMap) Set

func (m *BeeMap) Set(k interface{}, v interface{}) bool

Maps the given key and value. Returns false if the key is already in the map and changes nothing.

type Email

type Email struct {
	Auth        smtp.Auth
	Identity    string `json:"identity"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	From        string `json:"from"`
	To          []string
	Bcc         []string
	Cc          []string
	Subject     string
	Text        string // Plaintext message (optional)
	HTML        string // Html message (optional)
	Headers     textproto.MIMEHeader
	Attachments []*Attachment
	ReadReceipt []string
}

Email is the type used for email messages

func NewEMail

func NewEMail(config string) *Email

NewEMail create new Email struct with config json. config json is followed from Email struct fields.

func (*Email) Attach

func (e *Email) Attach(r io.Reader, filename string, c string) (a *Attachment, err error)

Attach is used to attach content from an io.Reader to the email. Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type.

func (*Email) AttachFile

func (e *Email) AttachFile(filename string) (a *Attachment, err error)

Add attach file to the send mail

func (*Email) Bytes

func (e *Email) Bytes() ([]byte, error)

Make all send information to byte

func (*Email) Send

func (e *Email) Send() error

type Page

type Page struct {
	Perpage      int64       //每页显示的条目数
	Nums         int64       //总条目数
	Current_page int64       //当前被选中的页
	Sub_pages    int64       //每次显示的页数
	PageNums     int64       //总页数
	Page_array   map[int]int //用来构造分页的数组
	SubPage_link string      //每个分页的链接
	SubPage_type int8        //显示分页的类型
}

func (*Page) Show

func (P *Page) Show() template.HTML

* 显示分页

Jump to

Keyboard shortcuts

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