utils

package
v0.0.0-...-a64d9b0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const TimeLimitCodeLength = 12 + 6 + 40

Variables

View Source
var ErrSphinxDBClosed = fmt.Errorf("SphinxDB already closed and give back to pools")
View Source
var SphinxPools *sphinxPools

Functions

func AssertIs

func AssertIs(a interface{}, args ...interface{}) error

func AssertNot

func AssertNot(a interface{}, args ...interface{}) error

func CreateTimeLimitCode

func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string

create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string

func EncodeHmac

func EncodeHmac(secret, value string, params ...func() hash.Hash) string

func EncodeMd5

func EncodeMd5(str string) string

Encode string to md5 hex value

func EncodePassword

func EncodePassword(rawPwd string, salt string) string

use pbkdf2 encode password

func FormChanges

func FormChanges(base interface{}, modified interface{}, skips ...string) (fields []string)

compare field values between two struct pointer return changed field names

func GetRandomString

func GetRandomString(n int) string

Random generate string

func InitSphinxPools

func InitSphinxPools() error

func IsMatchHost

func IsMatchHost(uri string) bool

func NumberDecode

func NumberDecode(token string, alphabet []byte) string

func NumberEncode

func NumberEncode(number string, alphabet []byte) string

func PBKDF2

func PBKDF2(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte

http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto

func ParseForm

func ParseForm(form interface{}, values url.Values)

parse request.Form values to form

func RegisterFieldCreater

func RegisterFieldCreater(name string, field FieldCreater)

register a custom label/input creater

func RegisterFieldFilter

func RegisterFieldFilter(name string, field FieldFilter)

register a custom label/input creater

func Render

func Render(content string) string

func RenderEmbedly

func RenderEmbedly(content string) string

func RenderMarkdown

func RenderMarkdown(mdStr string) string

func RenderReadability

func RenderReadability(content string, interpreter string) string

func RenderTemplate

func RenderTemplate(TplNames string, Data map[interface{}]interface{}) string

func SetFormValues

func SetFormValues(from interface{}, to interface{}, skips ...string)

set values from one struct to other struct both need ptr struct

func ThrowFail

func ThrowFail(t *testing.T, err error, args ...interface{})

func ThrowFailNow

func ThrowFailNow(t *testing.T, err error, args ...interface{})

func TimesReachedSet

func TimesReachedSet(key string, times int, reloadMinutes int)

func TimesReachedTest

func TimesReachedTest(key string, times int) (int, bool)

func ToInt64

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

convert any numeric value to int64

func ToStr

func ToStr(value interface{}, args ...int) (s string)

convert any type to string

func ValuesCompare

func ValuesCompare(is bool, a interface{}, args ...interface{}) (err error, ok bool)

func VerifyTimeLimitCode

func VerifyTimeLimitCode(data string, minutes int, code string) bool

verify time limit code

Types

type FieldCreater

type FieldCreater func(*FieldSet)

type FieldFilter

type FieldFilter func(*FieldSet)

type FieldSet

type FieldSet struct {
	Label       template.HTML
	Field       HtmlLazyField
	Id          string
	Name        string
	LabelText   string
	Value       interface{}
	Help        string
	Error       string
	Type        string
	Kind        string
	Placeholder string
	Attrs       string
	FormElm     reflect.Value
	Locale      FormLocaler
}

type FormHelper

type FormHelper interface {
	Helps() map[string]string
}

type FormLabeler

type FormLabeler interface {
	Labels() map[string]string
}

type FormLocaler

type FormLocaler interface {
	Tr(string, ...interface{}) string
}

type FormPlaceholder

type FormPlaceholder interface {
	Placeholders() map[string]string
}

type FormSets

type FormSets struct {
	FieldList []*FieldSet
	Fields    map[string]*FieldSet
	Locale    FormLocaler
	// contains filtered or unexported fields
}

func NewFormSets

func NewFormSets(form interface{}, errs map[string][]*validation.Error, locale FormLocaler) *FormSets

create formSets for generate label/field html code

func (*FormSets) SetError

func (this *FormSets) SetError(fieldName, errMsg string)

type HtmlLazyField

type HtmlLazyField func() template.HTML

func (HtmlLazyField) String

func (f HtmlLazyField) String() 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 SphinxDB

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

func (*SphinxDB) Close

func (s *SphinxDB) Close()

func (*SphinxDB) RawQuery

func (s *SphinxDB) RawQuery(query string, scans ...interface{}) (int64, error)

func (*SphinxDB) RawValuesFlat

func (s *SphinxDB) RawValuesFlat(query string, list *orm.ParamsList, column string) (int64, error)

func (*SphinxDB) ShowMeta

func (s *SphinxDB) ShowMeta() (*SphinxMeta, error)

type SphinxMeta

type SphinxMeta struct {
	Total      int
	TotalFound int64
	Time       float32
}

type StrTo

type StrTo string

func (StrTo) Bool

func (f StrTo) Bool() (bool, error)

func (*StrTo) Clear

func (f *StrTo) Clear()

func (StrTo) Exist

func (f StrTo) Exist() bool

func (StrTo) Float32

func (f StrTo) Float32() (float32, error)

func (StrTo) Float64

func (f StrTo) Float64() (float64, error)

func (StrTo) Int

func (f StrTo) Int() (int, error)

func (StrTo) Int16

func (f StrTo) Int16() (int16, error)

func (StrTo) Int32

func (f StrTo) Int32() (int32, error)

func (StrTo) Int64

func (f StrTo) Int64() (int64, error)

func (StrTo) Int8

func (f StrTo) Int8() (int8, error)

func (*StrTo) Set

func (f *StrTo) Set(v string)

func (StrTo) String

func (f StrTo) String() string

func (StrTo) Uint

func (f StrTo) Uint() (uint, error)

func (StrTo) Uint16

func (f StrTo) Uint16() (uint16, error)

func (StrTo) Uint32

func (f StrTo) Uint32() (uint32, error)

func (StrTo) Uint64

func (f StrTo) Uint64() (uint64, error)

func (StrTo) Uint8

func (f StrTo) Uint8() (uint8, error)

Jump to

Keyboard shortcuts

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