全局对象

gf框架封装了一些常用的数据类型以及对象,可以直接通过g.*方便获取。

使用方式:

  1. import "gitee.com/johng/gf/g"

数据类型

  1. // 常用map数据结构
  2. type Map map[string]interface{}
  3. // 常用list数据结构
  4. type List []Map

常用对象

  1. (单例)配置管理对象
    1. // 参数file未非必需参数,表示指定获取的配置文件管理对象
    2. func Config(file...string) *gcfg.Config
  2. (单例)模板引擎对象
    1. func View() *gview.View
  3. (单例)Http Server
    1. func Server(name...interface{}) *ghttp.Server
  4. (单例)TCP Server
    1. func TcpServer(name...interface{}) *gtcp.Server
  5. (单例)Udp Server
    1. func UdpServer(name...interface{}) *gudp.Server
  6. (单例)数据库ORM对象
    1. func Database(name...string) *gdb.Db
    2. // 别名
    3. func DB(name...string) *gdb.Db
  7. (单例)Redis客户端对象
    1. func Redis(name...string) *gredis.Redis