gogf / gf-demo-user Goto Github PK
View Code? Open in Web Editor NEWA simple user API service.
Home Page: https://goframe.org
License: MIT License
A simple user API service.
Home Page: https://goframe.org
License: MIT License
1.tmplate 中模板标记不生效${include .tplMain .}
2.需要自己手动修改config
3.chat.go cache.SetIfNotExist 聊天消息时间间隔不生效
该仓库不接受Issue提交,请提交到GF仓库地址:https://github.com/gogf/gf/issues
main.go:4:2: cannot find package "github.com/gogf/gf-demos/boot" in any of:
gf-demo在windows 10和go1.12.5环境下运行没反应,我测试了好几次,用gf 1.6.14 / gf 1.6.15 都可以,但是用gf 1.6.16 就不行,有群友反应在go.mod下运行有问题,但是在gopath模式下运行就正常。
2021-01-10 03:43:12.972 [ERRO] [252150 ms] [default] SELECT 语句
Error: bad connection
数据库的连接配置
[database]
link = "************************************************"
maxLifetime = 5 #"(可选,单位秒)连接对象可重复使用的时间长度"
maxIdle = 0 #"(可选)连接池最大闲置的连接数"
maxOpen = 100 #"(可选)连接池最大打开的连接数"
debug = true
# Database logger.
[database.logger]
Path = "/tmp/log/gf-lanbo/sql"
Level = "ERRO"
Stdout = true
一天大概会出现两三次 这样的情况
在router的init里面,g.Server()初始化webserver时,我想导入一个或多个变量,最终实现效果如下:
/router/router.go :
func init() {
conn, err := create_connection() //创建一个长连接,返回连接句柄conn
if err != nil {
glog.Error("esl connect freeswitch err: %v", err)
return
}
go conn.Handle()
s := g.Server() //初始化
s.BindObject("/reload",new(fs_esl.Controller)) //注册路由
}
上面init里面的conn句柄如何导入到下面这个函数中使用?
/app/api/fs_esl.go :
type Controller struct{}
func (c *Controller)Reloadxml(conn *Client, r *ghttp.Request){ //conn传参引入
if err := conn.BgApi("reloadxml"); err != nil { //调用conn发送命令
response.Json(r, 1, err.Error())
} else {
response.Json(r, 0, "reloadxml success!")
}
}
[redis]
default = "127.0.0.1:6379,0"
cache = "127.0.0.1:6379,1?idleTimeout=600"
怎么配置密码?
controller 中没有其他的返回接口,带 error 只能返回 5xx,无法返回 401/403 之类的错误
看调用栈也只是捕获了异常,没有利用 ctx 反向传递结果,请问这种架构下如何自定义返回码呢?
func (c *cUser) SignIn(ctx context.Context, req *v1.UserSignInReq) (res *v1.UserSignInRes, err error) {
err = service.User().SignIn(ctx, model.UserSignInInput{
Passport: req.Passport,
Password: req.Password,
})
return
}
如题:
glog.Error(err)
在 https://github.com/gogf/gf-demos/blob/master/app/controller/chat/chat.go 的 glog 中并无 Error 方法。
// 向客户端返回用户列表
func (c *Controller) writeUsers() error {
array := garray.NewSortedStringArray(0, false, false) //这里的 第二个参数不对 原来是0
names.Iterator(func(v string) bool {
array.Add(v)
return true
})
if err := c.writeGroup(Msg{"list", array.Slice(), ""}); err != nil {
return err
}
return nil
}
脚手架取名太随意了,拉下来每个文件都得改mod
internal/cmd/cmd.go:42
group.ALLMap(g.Map{
"/user/profile": userCtrl,
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.