utils

package
v0.0.0-...-81b66c4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: MIT, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitWithMsg

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

ExitWithMsg debug error messages and print stack

func GetLocale

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

func HumanizeString(str string) string

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

func ModelType

func ModelType(value interface{}) reflect.Type

ModelType get value's model type

func NewValue

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

NewValue new struct value with reflect type

func ParseTagOption

func ParseTagOption(str string) map[string]string

ParseTagOption parse tag options to hash

func PatchURL

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 "google.com" "key" "value"

func Stringify

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

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

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

func ToFloat

func ToFloat(value interface{}) float64

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

func ToInt

func ToInt(value interface{}) int64

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

func ToParamString

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

func ToString(value interface{}) string

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

func ToUint

func ToUint(value interface{}) uint64

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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