{"id":13827115,"url":"https://github.com/AmyangXYZ/sgo","last_synced_at":"2025-07-09T03:30:52.124Z","repository":{"id":57492037,"uuid":"112894756","full_name":"AmyangXYZ/sgo","owner":"AmyangXYZ","description":"A simple, light and fast Web framework written in Go.","archived":false,"fork":false,"pushed_at":"2021-11-16T05:11:23.000Z","size":1327,"stargazers_count":78,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T20:16:21.683Z","etag":null,"topics":["golang","lightweight","radix-tree","webframework"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AmyangXYZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-03T02:47:21.000Z","updated_at":"2024-12-09T12:01:00.000Z","dependencies_parsed_at":"2022-08-28T11:50:27.093Z","dependency_job_id":null,"html_url":"https://github.com/AmyangXYZ/sgo","commit_stats":null,"previous_names":["amyangxyz/sweetygo"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AmyangXYZ/sgo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmyangXYZ%2Fsgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmyangXYZ%2Fsgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmyangXYZ%2Fsgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmyangXYZ%2Fsgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmyangXYZ","download_url":"https://codeload.github.com/AmyangXYZ/sgo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmyangXYZ%2Fsgo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264386238,"owners_count":23599962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","lightweight","radix-tree","webframework"],"created_at":"2024-08-04T09:01:50.399Z","updated_at":"2025-07-09T03:30:51.747Z","avatar_url":"https://github.com/AmyangXYZ.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# SGo\n\nSGo is a simple, light and fast Web framework written in Go. \n\nThe source is easy to learn, then you can make your own Go Web Framework!\n\n## Features\n\n- Pretty and fast router - based on radix tree\n- Middleware Support\n- Friendly to REST API\n- No regexp or reflect\n- QUIC Support\n- Inspired by many excellent Go Web framework\n\n## Installation\n\n`go get github.com/AmyangXYZ/sgo`\n\n## Example\n\n### Simple\n\n```go\npackage main\n\nimport (\n    \"github.com/AmyangXYZ/sgo\"\n)\n\nfunc main() {\n    app := sgo.New()\n    app.GET(\"/\", func(ctx *sgo.Context) error {\n        return ctx.Text(200, \"Hello\")\n    })\n    app.Run(\":16311\")\n}\n\n```\n\n### Further\n\nFor vue2 projects, add `module.exports = {assetsDir: 'static', css: { extract: false }}` to vue.config.js, then `npm run build \u0026\u0026 tar caf dist.tar.xz dist` and copy dist.tar.xz and run `./deployFrontend.sh`.\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/AmyangXYZ/sgo\"\n\t\"github.com/gorilla/websocket\"\n)\n\nconst (\n\taddr = \":8888\"\n)\n\nvar upgrader = websocket.Upgrader{\n\tReadBufferSize:  1024,\n\tWriteBufferSize: 1024,\n}\n\nfunc main() {\n\tapp := sgo.New()\n\tapp.SetTemplates(\"./templates\", nil)\n\tapp.GET(\"/\", index)\n\tapp.GET(\"/static/*files\", static)\n\n\tapp.GET(\"/api/boottime\", getBootTime)\n\tapp.GET(\"/ws/comm\", wsComm)\n\tapp.POST(\"/api/link/:name\", postHandler)\n\tapp.OPTIONS(\"/api/link/:name\", sgo.PreflightHandler)\n\n\tif err := app.Run(addr); err != nil {\n\t\tlog.Fatal(\"Listen error\", err)\n\t}\n}\n\n// Index page handler.\nfunc index(ctx *sgo.Context) error {\n\treturn ctx.Render(200, \"index\")\n}\n\n// Static files handler.\nfunc static(ctx *sgo.Context) error {\n\tstaticHandle := http.StripPrefix(\"/static\",\n\t\thttp.FileServer(http.Dir(\"./static\")))\n\tstaticHandle.ServeHTTP(ctx.Resp, ctx.Req)\n\treturn nil\n}\n\nfunc getBootTime(ctx *sgo.Context) error {\n\treturn ctx.Text(200, fmt.Sprintf(\"%d\", 20))\n}\n\nfunc wsComm(ctx *sgo.Context) error {\n\tws, err := upgrader.Upgrade(ctx.Resp, ctx.Req, nil)\n\tbreakSig := make(chan bool)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(\"ws/comm connected\")\n\tdefer func() {\n\t\tws.Close()\n\t\tfmt.Println(\"ws/comm client closed\")\n\t}()\n\tgo func() {\n\t\tfor {\n\t\t\t_, _, err := ws.ReadMessage()\n\t\t\tif err != nil {\n\t\t\t\tbreakSig \u003c- true\n\t\t\t}\n\t\t}\n\t}()\n\tfor {\n\t\tselect {\n\t\t// case l := \u003c-LogsComm:\n\t\t// \tws.WriteJSON(l)\n\t\tcase \u003c-breakSig:\n\t\t\treturn errors.New(\"stop ws\")\n\t\t}\n\t}\n}\n\nfunc postHandler(ctx *sgo.Context) error {\n\t// param request\n\tfmt.Println(ctx.Params)\n\t// json body request\n\tbody, err := ioutil.ReadAll(ctx.Req.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Println(string(body))\n\tvar data map[string]interface{}\n\tjson.Unmarshal(body, \u0026data)\n\n\treturn ctx.Text(200, \"xx\")\n}\n```\n\n![example](https://raw.githubusercontent.com/AmyangXYZ/sgo/master/example/example.png)\n\nMy [Blog](https://amyang.xyz) is also powered by SGo.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAmyangXYZ%2Fsgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAmyangXYZ%2Fsgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAmyangXYZ%2Fsgo/lists"}