当前位置: 首页 > 后端技术 > PHP

PHP转Go,使用Laravel和thinkphp搭建ThinkGo框架

时间:2023-03-30 03:55:55 PHP

ThinkGo是一个轻量级的Go语言MVC框架,目前支持路由、中间件、控制器、请求、响应、会话、视图、日志等基础一个Web框架应该具备的功能,就是致力于让代码简洁、有表现力,帮助开发者快速构建一个Web应用。安装goget-ugithub.com/forgoer/thinkgo使用packagemainimport("github.com/forgoer/thinkgo""fmt""github.com/forgoer/thinkgo/router""github.com/forgoer/thinkgo/context")funcmain(){app:=thinkgo.BootStrap()app.RegisterRoute(func(route*router.Route){route.Get("/",func(req*context.Request)*context.Response{returnthinkgo.Text("HelloThinkGo!")})route.Get("/ping",func(req*context.Request)*context.Response{returnthinkgo.Json(map[string]string{"message":"pong",})})//依赖注入route.Get("/user/{name}",func(req*context.Request,namestring)*context.Response{returnthinkgo.Text(fmt.Sprintf("Hello%s!",name))})})//在0.0.0.0:9011上监听并服务app.Run()}项目地址GitHub:https://github.com/forgoer/th...大佬们快来指点贡献代码。..