beego: Index | Files | Directories

package utils

import ""


Package Files

caller.go debug.go file.go mail.go rand.go safemap.go slice.go utils.go

func Display Uses

func Display(data ...interface{})

Display print the data in console

func FileExists Uses

func FileExists(name string) bool

FileExists reports whether the named file or directory exists.

func GetDisplayString Uses

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

GetDisplayString return data print string

func GetFuncName Uses

func GetFuncName(i interface{}) string

GetFuncName get function name

func GetGOPATHs Uses

func GetGOPATHs() []string

GetGOPATHs returns all paths in GOPATH variable.

func GrepFile Uses

func GrepFile(patten string, filename string) (lines []string, err error)

GrepFile like command grep -E for example: GrepFile(`^hello`, "hello.txt") \n is striped while read

func InSlice Uses

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

InSlice checks given string in string slice or not.

func InSliceIface Uses

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

InSliceIface checks given interface in interface slice.

func RandomCreateBytes Uses

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

RandomCreateBytes generate random []byte by specify chars.

func SearchFile Uses

func SearchFile(filename string, paths ...string) (fullpath string, err error)

SearchFile Search a file in paths. this is often used in search config file in /etc ~/

func SelfDir Uses

func SelfDir() string

SelfDir gets compiled executable file directory

func SelfPath Uses

func SelfPath() string

SelfPath gets compiled executable file absolute path

func SliceChunk Uses

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

SliceChunk separates one slice to some sized slice.

func SliceDiff Uses

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

SliceDiff returns diff slice of slice1 - slice2.

func SliceFilter Uses

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

SliceFilter generates a new slice after filter function.

func SliceIntersect Uses

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

SliceIntersect returns slice that are present in all the slice1 and slice2.

func SliceMerge Uses

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

SliceMerge merges interface slices to one slice.

func SlicePad Uses

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

SlicePad prepends size number of val into slice.

func SliceRand Uses

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

SliceRand returns random one from slice.

func SliceRandList Uses

func SliceRandList(min, max int) []int

SliceRandList generate an int slice from min to max.

func SliceRange Uses

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 Uses

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

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

func SliceShuffle Uses

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

SliceShuffle shuffles a slice.

func SliceSum Uses

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

SliceSum sums all values in int64 slice.

func SliceUnique Uses

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

SliceUnique cleans repeated values in slice.

func Stack Uses

func Stack(skip int, indent string) []byte

Stack get stack bytes

type Attachment Uses

type Attachment utils.Attachment

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 Uses

type BeeMap utils.BeeMap

BeeMap is a map with lock

func NewBeeMap Uses

func NewBeeMap() *BeeMap

NewBeeMap return new safemap

func (*BeeMap) Check Uses

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

Check Returns true if k is exist in the map.

func (*BeeMap) Count Uses

func (m *BeeMap) Count() int

Count returns the number of items within the map.

func (*BeeMap) Delete Uses

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

Delete the given key and value.

func (*BeeMap) Get Uses

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

Get from maps return the k's value

func (*BeeMap) Items Uses

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

Items returns all items in safemap.

func (*BeeMap) Set Uses

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

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

type Email Uses

type Email utils.Email

Email is the type used for email messages

func NewEMail Uses

func NewEMail(config string) *Email

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

func (*Email) Attach Uses

func (e *Email) Attach(r io.Reader, filename string, args ...string) (*Attachment, 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 Uses

func (e *Email) AttachFile(args ...string) (*Attachment, error)

AttachFile Add attach file to the send mail

func (*Email) Bytes Uses

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

Bytes Make all send information to byte

func (*Email) Send Uses

func (e *Email) Send() error

Send will send out the mail


captchaPackage captcha implements generation and verification of image CAPTCHAs.
paginationPackage pagination provides utilities to setup a paginator within the context of a http request.

Package utils imports 2 packages (graph). Updated 2020-11-07. Refresh now. Tools for package owners.