Documentation ¶
Index ¶
- func Cfg(name ...string) *gcfg.Config
- func Client() *ghttp.Client
- func Config(name ...string) *gcfg.Config
- func DB(name ...string) gdb.DB
- func Database(name ...string) gdb.DB
- func Dump(i ...interface{})
- func Export(i ...interface{}) string
- func GetLogLevel() int
- func I18n(name ...string) *gi18n.Manager
- func IsEmpty(value interface{}) bool
- func IsNil(value interface{}, traceSource ...bool) bool
- func Listen()
- func Log(name ...string) *glog.Logger
- func Model(tables string, db ...string) *gdb.Model
- func Redis(name ...string) *gredis.Redis
- func Res(name ...string) *gres.Resource
- func Resource(name ...string) *gres.Resource
- func Server(name ...interface{}) *ghttp.Server
- func SetDebug(enabled bool)
- func SetLogLevel(level int)
- func TCPServer(name ...interface{}) *gtcp.Server
- func Table(tables string, db ...string) *gdb.Model
- func Throw(exception interface{})
- func Try(try func()) (err error)
- func TryCatch(try func(), catch ...func(exception error))
- func UDPServer(name ...interface{}) *gudp.Server
- func View(name ...string) *gview.View
- func Wait()
- type Array
- type ArrayAny
- type ArrayInt
- type ArrayStr
- type List
- type ListAnyAny
- type ListAnyBool
- type ListAnyInt
- type ListAnyStr
- type ListIntAny
- type ListIntBool
- type ListIntInt
- type ListIntStr
- type ListStrAny
- type ListStrBool
- type ListStrInt
- type ListStrStr
- type Map
- type MapAnyAny
- type MapAnyBool
- type MapAnyInt
- type MapAnyStr
- type MapIntAny
- type MapIntBool
- type MapIntInt
- type MapIntStr
- type MapStrAny
- type MapStrBool
- type MapStrInt
- type MapStrStr
- type Slice
- type SliceAny
- type SliceInt
- type SliceStr
- type Var
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Database ¶
Database returns an instance of database ORM object with specified configuration group name.
func Dump ¶
func Dump(i ...interface{})
Dump dumps a variable to stdout with more manually readable.
func Export ¶
func Export(i ...interface{}) string
Export exports a variable to string with more manually readable.
func GetLogLevel ¶
func GetLogLevel() int
GetLogLevel returns the global logging level. Deprecated, use functions of package glog or g.Log() instead.
func I18n ¶
I18n returns an instance of gi18n.Manager. The parameter <name> is the name for the instance.
func IsEmpty ¶
func IsEmpty(value interface{}) bool
IsEmpty checks whether given <value> empty. It returns true if <value> is in: 0, nil, false, "", len(slice/map/chan) == 0. Or else it returns true.
func IsNil ¶
IsNil checks whether given <value> is nil. Parameter <traceSource> is used for tracing to the source variable if given <value> is type of a pinter that also points to a pointer. It returns nil if the source is nil when <traceSource> is true. Note that it might use reflect feature which affects performance a little bit.
func Listen ¶
func Listen()
Listen is an alias of gproc.Listen, which handles the signals received and automatically calls registered signal handler functions. It blocks until shutdown signals received and all registered shutdown handlers done.
func Log ¶
Log returns an instance of glog.Logger. The parameter <name> is the name for the instance.
func Model ¶
Model creates and returns a model from specified database or default database configuration. The optional parameter <db> specifies the configuration group name of the database, which is "default" in default.
func Resource ¶
Resource returns an instance of Resource. The parameter <name> is the name for the instance.
func Server ¶
Server returns an instance of http server with specified name.
Example ¶
package main import ( "gitee.com/KotlinToGo/pkg/g" "gitee.com/KotlinToGo/pkg/net/ghttp" ) func main() { // A hello world example. s := g.Server() s.BindHandler("/", func(r *ghttp.Request) { r.Response.Write("hello world") }) s.SetPort(8999) s.Run() }
Output:
func SetLogLevel ¶
func SetLogLevel(level int)
SetLogLevel sets the logging level globally. Deprecated, use functions of package glog or g.Log() instead.
func Throw ¶
func Throw(exception interface{})
Throw throws a exception, which can be caught by TryCatch function. It always be used in TryCatch function.
func Try ¶
func Try(try func()) (err error)
Try implements try... logistics using internal panic...recover. It returns error if any exception occurs, or else it returns nil.
func TryCatch ¶
func TryCatch(try func(), catch ...func(exception error))
TryCatch implements try...catch... logistics using internal panic...recover. It automatically calls function <catch> if any exception occurs ans passes the exception as an error.
Types ¶
type ListAnyAny ¶
type ListAnyAny = []MapAnyAny
type ListAnyBool ¶
type ListAnyBool = []MapAnyBool
type ListAnyInt ¶
type ListAnyInt = []MapAnyInt
type ListAnyStr ¶
type ListAnyStr = []MapAnyStr
type ListIntAny ¶
type ListIntAny = []MapIntAny
type ListIntBool ¶
type ListIntBool = []MapIntBool
type ListIntInt ¶
type ListIntInt = []MapIntInt
type ListIntStr ¶
type ListIntStr = []MapIntStr
type ListStrAny ¶
type ListStrAny = []MapStrAny
type ListStrBool ¶
type ListStrBool = []MapStrBool
type ListStrInt ¶
type ListStrInt = []MapStrInt
type ListStrStr ¶
type ListStrStr = []MapStrStr
type MapAnyBool ¶
type MapAnyBool = map[interface{}]bool