Faygo
Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct handler, faygo will automatically bind/verify the request parameters and generate the online API doc.
Install / Use
/learn @andeya/FaygoREADME
Faygo
-27a5ea.svg?style=flat-square)

Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct Handler, Faygo will automatically bind/verify the request parameters and generate the online API doc. Go to <User Manual>



Latest version
Version
v1.2.0
Requirements
Go Version ≥ 1.8
Quick Start
- Way 1: download source
go get -u -v github.com/andeya/faygo
- Way 2: deployment tools (Go to fay)
go get -u -v github.com/andeya/fay
fay command [arguments]
The commands are:
new create, compile and run (monitor changes) a new faygo project
run compile and run (monitor changes) an any existing go project
fay new appname [apptpl]
appname specifies the path of the new faygo project
apptpl optionally, specifies the faygo project template type
fay run [appname]
appname optionally, specifies the path of the new project
Features
- One
struct Handlercan get more things:
- Define Handler/Middleware
- Bind and verify request parameters
- Generate an online document for the Swagger 2.0 API
- Database ORM mapping
- Handler and Middleware are exactly the same, both implement the Handler interface (
funcorstruct), which together constitute the handler chain of the router. - Supports multiple network types:
Network types | Configuration net_types
----------------------------------------------|----------------
HTTP | http
HTTPS/HTTP2(TLS) | https
HTTPS/HTTP2(Let's Encrypt TLS) | letsencrypt
HTTPS/HTTP2(Let's Encrypt TLS on UNIX socket) | unix_letsencrypt
HTTP(UNIX socket) | unix_http
HTTPS/HTTP2(TLS on UNIX socket) | unix_https
- Support single-service & single-listener, single-service & multi-listener, multi-service & multi-listener and so on. The config of multiple services is independent of each other
- The high-performance router based on
httproutersupports both chain and tree registration styles; supports flexible static file router (such as DirFS, RenderFS, MarkdownFS, etc.) - Support graceful shutdown and rebooting, provide fay tools which has new projects, hot compilation , meta programming function
- Use the most powerful
pongo2as the HTML rendering engine - Support near-LRU memory caching (mainly used for static file cache)
- Support cross-platform color log system, and has two output interface(console and file)
- Support session management (If you use a persistent storage engine, you must use gob.Register() to register the relevant custom type before starting the service)
- Support global gzip compression config
- Support XSRF security filtering
- Most features try to use simple ini configs to avoid unnecessary recompilation, and these profiles can be automatically assigned default values
- Provide
gorm,xorm,sqlx,directSQL,Websocket,ini,http clientand many other commonly used expansion packages

Simple example
package main
import (
// "mime/multipart"
"time"
"github.com/andeya/faygo"
)
type Index struct {
Id int `param:"<in:path> <required> <desc:ID> <range: 0:10>"`
Title string `param:"<in:query> <nonzero>"`
Paragraph []string `param:"<in:query> <name:p> <len: 1:10> <regexp: ^[\\w]*$>"`
Cookie string `param:"<in:cookie> <name:faygoID>"`
// Picture *multipart.FileHeader `param:"<in:formData> <name:pic> <maxmb:30>"`
}
func (i *Index) Serve(ctx *faygo.Context) error {
if ctx.CookieParam("faygoID") == "" {
ctx.SetCookie("faygoID", time.Now().String())
}
return ctx.JSON(200, i)
}
func main() {
app := faygo.New("myapp", "0.1")
// Register the route in a chain style
app.GET("/index/:id", new(Index))
// Register the route in a tree style
// app.Route(
// app.NewGET("/index/:id", new(Index)),
// )
// Start the service
faygo.Run()
}
/*
http GET:
http://localhost:8080/index/1?title=test&p=abc&p=xyz
response:
{
"Id": 1,
"Title": "test",
"Paragraph": [
"abc",
"xyz"
],
"Cookie": "2016-11-13 01:14:40.9038005 +0800 CST"
}
*/
Handler and middleware
Handler and middleware are the same, both implemente Handler interface!
- function type
// Page handler doesn't contains API doc description
func Page() faygo.HandlerFunc {
return func(ctx *faygo.Context) error {
return ctx.String(200, "faygo")
}
}
// Page2 handler contains API doc description
var Page2 = faygo.WrapDoc(Page(), "test page2 notes", "test")
- struct type
// Param binds and validates the request parameters by Tags
type Param struct {
Id int `param:"<in:path> <required> <desc:ID> <range: 0:10>"`
Title string `param:"<in:query>"`
}
// Serve implemente Handler interface
func (p *Param) Serve(ctx *faygo.Context) error {
return ctx.JSON(200,
faygo.Map{
"Struct Params": p,
"Additional Param": ctx.PathParam("additional"),
}, true)
}
// Doc implemente API Doc interface (optional)
func (p *Param) Doc() faygo.Doc {
return faygo.Doc{
// Add the API notes to the API doc
Note: "param desc",
// declare the response content format to the API doc
Return: faygo.JSONMsg{
Code: 1,
Info: "success",
},
// additional request parameter declarations to the API doc (optional)
Params: []faygo.ParamInfo{
{
Name: "additional",
In: "path",
Model: "a",
Desc: "defined by the `Doc()` method",
},
},
}
}
Filter function
The filter function must be HandleFunc type!
func Root2Index(ctx *faygo.Context) error {
// Direct access to `/index` is not allowed
if ctx.Path() == "/index" {
ctx.Stop()
return nil
}
if ctx.Path() == "/" {
ctx.ModifyPath("/index")
}
return nil
}
Route registration
- tree style
// New application object, params: name, version
var app1 = faygo.New("myapp1", "1.0")
// router
app1.Filter(Root2Index).
Route(
app1.NewNamedGET("test page", "/page", Page()),
app1.NewNamedGET("test page2", "/page2", Page2),
app1.NewGroup("home",
app1.NewNamedGET("test param", "/param", &Param{
// sets the default value in the API documentation for the request parameters (optional)
Id: 1,
Title: "test param",
}),
),
)
- chain style
// New application object, params: name, version
var app2 = faygo.New("myapp2", "1.0")
// router
app2.Filter(Root2Index)
app2.NamedGET("test page", "/page", Page())
app2.NamedGET("test page2", "/page2", Page2)
app2.Group("home")
{
app2.NamedGET("test param", "/param", &Param{
// sets the default value in the API documentation for the request parameters(optional)
Id: 1,
Title: "test param",
})
}
Shutdown and reboot
- shutdown gracefully
kill [pid]
- reboot gracefully
kill -USR2 [pid]
Configuration
- Each instance of the application has a single config (file name format
config/{appname}[_{version}].ini). Refer to the following:
net_types = http|https # List of network type: http | https | unix_http | unix_https | letsencrypt | unix_letsencrypt
addrs = 0.0.0.0:80|0.0.0.0:443 # List of multiple listening addresses
tls_certfile = # TLS certificate file path
tls_keyfile = # TLS key file path
letsencrypt_dir = # Let's Encrypt TLS certificate cache directory
unix_filemode = 0666 # File permissions for UNIX listener, requires octal number
http_redirect_https = false # Redirect from 'http://hostn
Related Skills
xurl
334.9kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
kubeshark
11.8kCluster-wide network observability for Kubernetes. Captures L4 packets, L7 API calls, and decrypted TLS traffic using eBPF, with full Kubernetes context. Available to AI agents via MCP and human operators via dashboard.
wanwu
4.2kChina Unicom's Yuanjing Wanwu Agent Platform is an enterprise-grade, multi-tenant AI agent development platform. It helps users build applications such as intelligent agents, workflows, and rag, and also supports model management. The platform features a developer-friendly license, and we welcome all developers to build upon the platform.
gin-vue-admin
24.5k🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,企业级业务AI+开发解决方案,内置mcp辅助服务,内置skills管理,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。
