g

package
v1.15.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 16 Imported by: 618

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cfg

func Cfg(name ...string) *gcfg.Config

Cfg is alias of Config. See Config.

func Client added in v1.12.0

func Client() *ghttp.Client

Client is a convenience function, that creates and returns a new HTTP client.

func Config

func Config(name ...string) *gcfg.Config

Config returns an instance of config object with specified name.

func DB

func DB(name ...string) gdb.DB

DB returns an instance of database ORM object with specified configuration group name.

func Database

func Database(name ...string) gdb.DB

Database is alias of DB. See DB. Deprecated, use DB instead.

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

func I18n(name ...string) *gi18n.Manager

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 added in v1.11.5

func IsNil(value interface{}, traceSource ...bool) bool

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 added in v1.15.2

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 added in v1.10.0

func Log(name ...string) *glog.Logger

Log returns an instance of glog.Logger. The parameter <name> is the name for the instance.

func Model added in v1.13.2

func Model(tables ...string) *gdb.Model

Model creates and returns a model based on configuration of default database group.

func Redis

func Redis(name ...string) *gredis.Redis

Redis returns an instance of redis client with specified configuration group name.

func Res

func Res(name ...string) *gres.Resource

Res is alias of Resource. See Resource.

func Resource

func Resource(name ...string) *gres.Resource

Resource returns an instance of Resource. The parameter <name> is the name for the instance.

func Server

func Server(name ...interface{}) *ghttp.Server

Server returns an instance of http server with specified name.

Example
package main

import (
	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/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 SetDebug

func SetDebug(enabled bool)

SetEnabled enables/disables the GoFrame internal logging manually. Note that this function is not concurrent safe, be aware of the DATA RACE, which means you should call this function in your boot but not the runtime.

func SetLogLevel

func SetLogLevel(level int)

SetLogLevel sets the logging level globally. Deprecated, use functions of package glog or g.Log() instead.

func SetServerGraceful

func SetServerGraceful(enabled bool)

SetServerGraceful enables/disables graceful reload feature of http Web Server. This feature is disabled in default. Deprecated, use configuration of ghttp.Server for controlling this feature.

func TCPServer

func TCPServer(name ...interface{}) *gtcp.Server

TCPServer returns an instance of tcp server with specified name.

func Table added in v1.12.2

func Table(tables ...string) *gdb.Model

Table is alias of Model. The database component is designed not only for relational databases but also for NoSQL databases in the future. The name "Table" is not proper for that purpose any more. Deprecated, use Model 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 added in v1.14.1

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.

func UDPServer

func UDPServer(name ...interface{}) *gudp.Server

UDPServer returns an instance of udp server with specified name.

func View

func View(name ...string) *gview.View

View returns an instance of template engine object with specified name.

func Wait

func Wait()

Wait is an alias of ghttp.Wait, which blocks until all the web servers shutdown. It's commonly used in multiple servers situation.

func With added in v1.15.4

func With(object interface{}) *gdb.Model

With creates and returns an ORM model based on meta data of given object.

Types

type Array

type Array = []interface{}

Array is alias of Slice.

type ArrayAny

type ArrayAny = []interface{}

Array is alias of Slice.

type ArrayInt

type ArrayInt = []int

Array is alias of Slice.

type ArrayStr

type ArrayStr = []string

Array is alias of Slice.

type List

type List = []Map

Frequently-used slice alias.

type ListAnyAny added in v1.9.10

type ListAnyAny = []MapAnyAny

Frequently-used slice alias.

type ListAnyBool

type ListAnyBool = []MapAnyBool

Frequently-used slice alias.

type ListAnyInt

type ListAnyInt = []MapAnyInt

Frequently-used slice alias.

type ListAnyStr

type ListAnyStr = []MapAnyStr

Frequently-used slice alias.

type ListIntAny

type ListIntAny = []MapIntAny

Frequently-used slice alias.

type ListIntBool

type ListIntBool = []MapIntBool

Frequently-used slice alias.

type ListIntInt

type ListIntInt = []MapIntInt

Frequently-used slice alias.

type ListIntStr

type ListIntStr = []MapIntStr

Frequently-used slice alias.

type ListStrAny

type ListStrAny = []MapStrAny

Frequently-used slice alias.

type ListStrBool

type ListStrBool = []MapStrBool

Frequently-used slice alias.

type ListStrInt

type ListStrInt = []MapStrInt

Frequently-used slice alias.

type ListStrStr

type ListStrStr = []MapStrStr

Frequently-used slice alias.

type Map

type Map = map[string]interface{}

Frequently-used map alias.

type MapAnyAny

type MapAnyAny = map[interface{}]interface{}

Frequently-used map alias.

type MapAnyBool

type MapAnyBool = map[interface{}]bool

Frequently-used map alias.

type MapAnyInt

type MapAnyInt = map[interface{}]int

Frequently-used map alias.

type MapAnyStr

type MapAnyStr = map[interface{}]string

Frequently-used map alias.

type MapIntAny

type MapIntAny = map[int]interface{}

Frequently-used map alias.

type MapIntBool

type MapIntBool = map[int]bool

Frequently-used map alias.

type MapIntInt

type MapIntInt = map[int]int

Frequently-used map alias.

type MapIntStr

type MapIntStr = map[int]string

Frequently-used map alias.

type MapStrAny

type MapStrAny = map[string]interface{}

Frequently-used map alias.

type MapStrBool

type MapStrBool = map[string]bool

Frequently-used map alias.

type MapStrInt

type MapStrInt = map[string]int

Frequently-used map alias.

type MapStrStr

type MapStrStr = map[string]string

Frequently-used map alias.

type Slice

type Slice = []interface{}

Frequently-used slice alias.

type SliceAny

type SliceAny = []interface{}

Frequently-used slice alias.

type SliceInt

type SliceInt = []int

Frequently-used slice alias.

type SliceStr

type SliceStr = []string

Frequently-used slice alias.

type Var

type Var = gvar.Var

Var is a universal variable interface, like generics.

func NewVar

func NewVar(i interface{}, safe ...bool) *Var

NewVar returns a gvar.Var.

Jump to

Keyboard shortcuts

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