adsa-cms: Index | Files

package utils

import ""


Package Files

meta.go utils.go

func ExitWithMsg Uses

func ExitWithMsg(msg interface{}, value ...interface{})

ExitWithMsg debug error messages and print stack

func GetLocale Uses

func GetLocale(context *qor.Context) string

GetLocale get locale from request, cookie, after get the locale, will write the locale to the cookie if possible

func HumanizeString Uses

func HumanizeString(str string) string

HumanizeString Humanize separates string based on capitalizd letters e.g. "OrderItem" -> "Order Item"

func ModelType Uses

func ModelType(value interface{}) reflect.Type

ModelType get value's model type

func NewValue Uses

func NewValue(t reflect.Type) (v reflect.Value)

NewValue new struct value with reflect type

func ParseTagOption Uses

func ParseTagOption(str string) map[string]string

ParseTagOption parse tag options to hash

func PatchURL Uses

func PatchURL(originalURL string, params ...interface{}) (patchedURL string, err error)

PatchURL updates the query part of the current request url. You can access it in template by `patch_url`.

patch_url "" "key" "value"

func SetCookie Uses

func SetCookie(cookie http.Cookie, context *qor.Context)

SetCookie set cookie for context

func Stringify Uses

func Stringify(object interface{}) string

Stringify stringify any data, if it is a struct, will try to use its Name, Title, Code field, else will use its primary key

func ToArray Uses

func ToArray(value interface{}) (values []string)

ToArray get array from value, will ignore blank string to convert it to array

func ToFloat Uses

func ToFloat(value interface{}) float64

ToFloat get float from value, if passed value is empty string, result will be 0

func ToInt Uses

func ToInt(value interface{}) int64

ToInt get int from value, if passed value is empty string, result will be 0

func ToParamString Uses

func ToParamString(str string) string

ToParamString replaces spaces and separates words (by uppercase letters) with underscores in a string, also downcase it e.g. ToParamString -> to_param_string, To ParamString -> to_param_string

func ToString Uses

func ToString(value interface{}) string

ToString get string from value, if passed value is a slice, will use the first element

func ToUint Uses

func ToUint(value interface{}) uint64

ToUint get uint from value, if passed value is empty string, result will be 0

Package utils imports 13 packages (graph) and is imported by 15 packages. Updated 2017-06-08. Refresh now. Tools for package owners.