fix issue in gconv.Struct* functions panic when converting attribute value is nil

This commit is contained in:
John
2020-02-05 22:02:49 +08:00
parent 4d2b244319
commit b15075fdfe
7 changed files with 136 additions and 12 deletions

View File

@ -9,14 +9,14 @@ import (
func main() {
s := g.Server()
s.Group("/", func(group *ghttp.RouterGroup) {
g.GET("/set", func(r *ghttp.Request) {
group.GET("/set", func(r *ghttp.Request) {
r.Session.Set("time", gtime.Timestamp())
r.Response.Write("ok")
})
g.GET("/get", func(r *ghttp.Request) {
group.GET("/get", func(r *ghttp.Request) {
r.Response.WriteJson(r.Session.Map())
})
g.GET("/clear", func(r *ghttp.Request) {
group.GET("/clear", func(r *ghttp.Request) {
r.Session.Clear()
})
})

View File

@ -0,0 +1,29 @@
package main
import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gsession"
"github.com/gogf/gf/os/gtime"
"time"
)
func main() {
s := g.Server()
s.SetSessionMaxAge(2 * time.Minute)
s.SetSessionStorage(gsession.NewStorageRedis(g.Redis()))
s.Group("/", func(group *ghttp.RouterGroup) {
group.GET("/set", func(r *ghttp.Request) {
r.Session.Set("time", gtime.Timestamp())
r.Response.Write("ok")
})
group.GET("/get", func(r *ghttp.Request) {
r.Response.WriteJson(r.Session.Map())
})
group.GET("/clear", func(r *ghttp.Request) {
r.Session.Clear()
})
})
s.SetPort(8199)
s.Run()
}