Documentation ¶
Index ¶
- Variables
- type APIServer
- type C
- type CacheAssistant
- type Controller
- type DBAssistant
- func (s *DBAssistant) DB(id ...string) gcore.Database
- func (s *DBAssistant) Init(cfg gcore.Config) error
- func (s *DBAssistant) InitFromFile(cfgFile string) error
- func (s *DBAssistant) MySQL(id ...string) *gdb.MySQLDB
- func (s *DBAssistant) SQLite3(id ...string) *gdb.SQLite3DB
- func (s *DBAssistant) Table(tableName string) *gdb.Model
- type ErrorAssistant
- type HTTPServer
- type I18nAssistant
- type NewAssistant
- func (s *NewAssistant) APIServer(ctx gcore.Ctx, address string) (gcore.APIServer, error)
- func (s *NewAssistant) APIServerDefault(ctx gcore.Ctx) (gcore.APIServer, error)
- func (s *NewAssistant) App() gcore.App
- func (s *NewAssistant) AppDefault() gcore.App
- func (s *NewAssistant) Captcha() *gcaptcha.Captcha
- func (s *NewAssistant) CaptchaDefault() *gcaptcha.Captcha
- func (s *NewAssistant) Config() gcore.Config
- func (s *NewAssistant) ConfigFile(file string) (cfg gcore.Config, err error)
- func (s *NewAssistant) Ctx() gcore.Ctx
- func (s *NewAssistant) HTTPServer(ctx gcore.Ctx) gcore.HTTPServer
- func (s *NewAssistant) Logger(ctx gcore.Ctx, prefix string) gcore.Logger
- func (s *NewAssistant) Map() *gmap.Map
- func (s *NewAssistant) Router(ctx gcore.Ctx) gcore.HTTPRouter
- func (s *NewAssistant) Tr(lang string, ctx gcore.Ctx) (tr gcore.I18n)
- type P
- type R
- type W
Constants ¶
This section is empty.
Variables ¶
var ( // New shortcut of New gmc stuff New = &NewAssistant{} // DB shortcut of gmc database stuff DB = &DBAssistant{} // Cache shortcut of gmc cache stuff Cache = &CacheAssistant{} // I18n shortcut of gmc i18n I18n = &I18nAssistant{} // Err shortcut of gerror Err = &ErrorAssistant{} )
Functions ¶
This section is empty.
Types ¶
type APIServer ¶
type APIServer = ghttpserver.APIServer
APIServer Alias of type ghttpserver.APIServer
type CacheAssistant ¶
type CacheAssistant struct { }
CacheAssistant helper to access cache, Init Must be called firstly with config object of app.toml.
func (*CacheAssistant) Cache ¶
func (s *CacheAssistant) Cache(id ...string) gcore.Cache
Cache acquires the default cache object, you must be call Init firstly.
func (*CacheAssistant) File ¶
func (s *CacheAssistant) File(id ...string) *gcache.FileCache
File acquires the default file cache object, you must be call Init firstly.
func (*CacheAssistant) Init ¶
func (s *CacheAssistant) Init(cfg gcore.Config) error
Init initialize the cache group objects from a config object contains app.toml section cache.
func (*CacheAssistant) Memory ¶
func (s *CacheAssistant) Memory(id ...string) *gcache.MemCache
Memory acquires the default memory cache object, you must be call Init firstly.
func (*CacheAssistant) Redis ¶
func (s *CacheAssistant) Redis(id ...string) *gcache.RedisCache
Redis acquires the default redis cache object, you must be call Init firstly.
type Controller ¶
type Controller = gcontroller.Controller
Controller Alias of type gcontroller.Controller
type DBAssistant ¶
type DBAssistant struct { }
DBAssistant helper to access database, DB.Init Must be called firstly with config object of app.toml.
func (*DBAssistant) DB ¶
func (s *DBAssistant) DB(id ...string) gcore.Database
DB acquires the default db group object, you must be call Init firstly. And you must assert it to the correct type to use.
func (*DBAssistant) Init ¶
func (s *DBAssistant) Init(cfg gcore.Config) error
Init initialize the db group objects from a config object contains app.toml section [database].
func (*DBAssistant) InitFromFile ¶
func (s *DBAssistant) InitFromFile(cfgFile string) error
InitFromFile initialize the db group objects from a foo.toml config file. foo.toml must be contains section [database].
func (*DBAssistant) MySQL ¶
func (s *DBAssistant) MySQL(id ...string) *gdb.MySQLDB
MySQL acquires the mysql db group object, you must be call Init firstly.
type ErrorAssistant ¶
type ErrorAssistant struct {
// contains filtered or unexported fields
}
ErrorAssistant helper to using error or add stack info to error.
func NewErrorAssistant ¶
func NewErrorAssistant() *ErrorAssistant
NewErrorAssistant returns new a ErrorAssistant object.
func (*ErrorAssistant) New ¶
func (e *ErrorAssistant) New(err interface{}) error
New creates a gcore.Error from an error or string, the gcore.Error keeps the full stack information.
func (*ErrorAssistant) Recover ¶
func (e *ErrorAssistant) Recover(f ...interface{})
Recover catch fatal error in defer, f can be func(err interface{}) or string or object as string
func (*ErrorAssistant) Stack ¶
func (e *ErrorAssistant) Stack(err interface{}) string
Stack acquires an error full stack info string
func (*ErrorAssistant) Wrap ¶
func (e *ErrorAssistant) Wrap(err interface{}) error
Wrap wraps an error to gcore.Error, which keeps the full stack information.
type HTTPServer ¶
type HTTPServer = ghttpserver.HTTPServer
HTTPServer Alias of type ghttpserver.HTTPServer
type I18nAssistant ¶
type I18nAssistant struct { }
I18nAssistant helper to using i18n, Init Must be called firstly with config object of app.toml.
func (*I18nAssistant) Init ¶
func (s *I18nAssistant) Init(cfg gcore.Config) (i18n gcore.I18n, err error)
Init initialize the i18n object from a config object contains app.toml section [i18n].
type NewAssistant ¶
type NewAssistant struct { }
NewAssistant helper to new different gmc objects.
func (*NewAssistant) APIServer ¶
func (s *NewAssistant) APIServer(ctx gcore.Ctx, address string) (gcore.APIServer, error)
APIServer creates a new object of gmc.APIServer
func (*NewAssistant) APIServerDefault ¶
func (s *NewAssistant) APIServerDefault(ctx gcore.Ctx) (gcore.APIServer, error)
APIServerDefault creates a new object of gmc.APIServer and initialized from app.toml [apiserver] section. cfg is a gconfig.Config object contains section [apiserver] in `app.toml`.
func (*NewAssistant) App ¶
func (s *NewAssistant) App() gcore.App
App creates an new object of gcore.App
func (*NewAssistant) AppDefault ¶
func (s *NewAssistant) AppDefault() gcore.App
AppDefault creates a new object of APP and search config file locations: ./app.toml or ./conf/app.toml or ./config/app.toml
func (*NewAssistant) Captcha ¶
func (s *NewAssistant) Captcha() *gcaptcha.Captcha
Captcha creates an captcha object
func (*NewAssistant) CaptchaDefault ¶
func (s *NewAssistant) CaptchaDefault() *gcaptcha.Captcha
CaptchaDefault creates an captcha object, and sets default configuration
func (*NewAssistant) Config ¶
func (s *NewAssistant) Config() gcore.Config
Config creates a new object of gconfig.Config
func (*NewAssistant) ConfigFile ¶
func (s *NewAssistant) ConfigFile(file string) (cfg gcore.Config, err error)
ConfigFile creates a new object of gconfig.Config from a toml file.
func (*NewAssistant) Ctx ¶
func (s *NewAssistant) Ctx() gcore.Ctx
Ctx creates an new object of gcore.Ctx
func (*NewAssistant) HTTPServer ¶
func (s *NewAssistant) HTTPServer(ctx gcore.Ctx) gcore.HTTPServer
HTTPServer creates a new object of gmc.HTTPServer
func (*NewAssistant) Logger ¶
func (s *NewAssistant) Logger(ctx gcore.Ctx, prefix string) gcore.Logger
Logger creates an new object of gcore.Logger
func (*NewAssistant) Map ¶
func (s *NewAssistant) Map() *gmap.Map
Map creates a gmap.Map object, gmap.Map's keys are sequenced.
func (*NewAssistant) Router ¶
func (s *NewAssistant) Router(ctx gcore.Ctx) gcore.HTTPRouter
Router creates a new object of gcore.HTTPRouter
func (*NewAssistant) Tr ¶
func (s *NewAssistant) Tr(lang string, ctx gcore.Ctx) (tr gcore.I18n)
Tr creates an new object of gi18n.I18nTool This only worked after gmc.I18n.Init() called. lang is the language translation to.
Directories ¶
Path | Synopsis |
---|---|
demos
|
|
website
Module
|
|
http
|
|
router
Package grouter is a trie based high performance HTTP request router.
|
Package grouter is a trie based high performance HTTP request router. |
internal
|
|
using
|
|
util
|
|
args
Package gargs implements a simple lexer which splits input in to tokens using shell-style rules for quoting and commenting.
|
Package gargs implements a simple lexer which splits input in to tokens using shell-style rules for quoting and commenting. |
cast
Package gcast provides easy and safe casting in Go.
|
Package gcast provides easy and safe casting in Go. |
compress
Package gcompress allows you to easily unpack *.tar.gz, *.tar.bzip2, *.tar.xz, *.zip and *.tar files.
|
Package gcompress allows you to easily unpack *.tar.gz, *.tar.bzip2, *.tar.xz, *.zip and *.tar files. |
gpool
Package gpool is a goroutine pool, it is concurrency safed, it can using a few goroutine to run a huge tasks.
|
Package gpool is a goroutine pool, it is concurrency safed, it can using a few goroutine to run a huge tasks. |
linklist
Package glinklist implements a doubly linked list.
|
Package glinklist implements a doubly linked list. |
process/daemon
Package gdaemon does add daemon, logging and forever function to your program.
|
Package gdaemon does add daemon, logging and forever function to your program. |
process/hook
Package ghook package does prevent your program main function to exit when all your worker code in goroutine.
|
Package ghook package does prevent your program main function to exit when all your worker code in goroutine. |
process/profiling
Package gprofiling package help you do profiling your program in easy way.
|
Package gprofiling package help you do profiling your program in easy way. |