gmc

package module
v0.0.0-...-9935139 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 14 Imported by: 10

README

GMC Web & API Framework

Actions Status codecov Go Report API Reference LICENSE

GMC is a smart and flexible golang web and api development framework. GMC goal is high performance, good productivity and write less code to do more things.

Contents

USER GUIDE使用指南

Attention

this project is undergoing development, will be changed frequently.

Pull Request

PR is welcomed, but you should keep well code specification, such as : comment, testing, benchmark, example.

A package must be include the fllowing files:

xxx is package name.

File Description
xxx.go main file
xxx_test.go testing file, code coverage must be than 90%
example_test.go each public function example code
benchmark_test.go benchmark testing file
doc.go description of package
README.md testing and benchmarkresult must be include

You can reference the package sync/gpool to get more information about code specification.

Thanks

JetBrains

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 C

type C = gcore.Ctx

C Alias of type gcore.Ctx

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.

func (*DBAssistant) SQLite3

func (s *DBAssistant) SQLite3(id ...string) *gdb.SQLite3DB

SQLite3 acquires the sqlite3 db group object, you must be call Init firstly.

func (*DBAssistant) Table

func (s *DBAssistant) Table(tableName string) *gdb.Model

Table acquires the table model 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.

type P

type P = gcore.Params

P Alias of type gcore.Params

type R

type R = *http.Request

R Alias of type *http.Request

type W

type W = http.ResponseWriter

W Alias of type http.ResponseWriter

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
app
ctx
db
log
using
db
web
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.
env
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.
map
net
os
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.
set
url

Jump to

Keyboard shortcuts

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