profile
viewpoint

Ask questionspanic JSON Render

  • go version: go version go1.14.1 darwin/amd64
  • gin version (or commit ref): 1.6.3
  • operating system:
2020/06/12 14:27:43 http: panic serving 127.0.0.1:52658: write tcp 127.0.0.1:80->127.0.0.1:52658: write: broken pipe
goroutine 34342467 [running]:
net/http.(*conn).serve.func1(0xc00024dae0)
	/usr/local/go/src/net/http/server.go:1772 +0x139
panic(0x1071f40, 0xc001250f00)
	/usr/local/go/src/runtime/panic.go:975 +0x3e3
github.com/gin-gonic/gin/render.JSON.Render(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/render/json.go:59
github.com/gin-gonic/gin.(*Context).Render(0xc0008490e0, 0x1f4, 0x138dfe0, 0xc000ebdcf0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:841 +0x146
github.com/gin-gonic/gin.(*Context).JSON(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:884
pkg.poizon.com/golang/go-common/globally.(*Handler).RecoveryWithLogger.func1.1(0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/globally/handler.go:53 +0x370
panic(0x1071f40, 0xc001250f00)
	/usr/local/go/src/runtime/panic.go:969 +0x166
github.com/gin-gonic/gin/render.JSON.Render(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/render/json.go:59
github.com/gin-gonic/gin.(*Context).Render(0xc0008490e0, 0xc8, 0x138dfe0, 0xc000ebdb50)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:841 +0x146
github.com/gin-gonic/gin.(*Context).JSON(...)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:884
pkg.poizon.com/golang/go-common/gin_controller.(*Controller).Response(0xc000402420, 0xc0008490e0, 0xf84fc0, 0xc001094bc0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/gin_controller/controller.go:48 +0x17a
pkg.poizon.com/sns/sns-content/pkg/controllers.(*ContentController).Detail(0xc000402420, 0xc0008490e0)
	/drone/src/pkg/controllers/content.go:44 +0x16a
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
pkg.poizon.com/golang/go-common/server.(*GinServer).Localizer(0xc0000a4360, 0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/server/server.go:164 +0x1d9
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
pkg.poizon.com/golang/go-common/tracer.(*TracerServer).MiddlewareTracerFunc(0xc0007803f0, 0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/tracer/server.go:87 +0x651
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
pkg.poizon.com/golang/go-common/server.(*Prometheus).HandlerFunc.func1(0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/server/prometheus.go:325 +0xbc
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
pkg.poizon.com/golang/go-common/globally.(*Access).GinZap.func1(0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/globally/access.go:37 +0xfad
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
pkg.poizon.com/golang/go-common/globally.(*Handler).RecoveryWithLogger.func1(0xc0008490e0)
	/go/pkg/mod/pkg.poizon.com/golang/go-common@v0.0.0-20200608152559-b4436c72198f/globally/handler.go:67 +0x4e
github.com/gin-gonic/gin.(*Context).Next(0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/context.go:161 +0x3b
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc0001f4a00, 0xc0008490e0)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:409 +0x666
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc0001f4a00, 0x1395ee0, 0xc00138c2a0, 0xc000d2ae00)
	/go/pkg/mod/github.com/gin-gonic/gin@v1.6.3/gin.go:367 +0x14d
net/http.serverHandler.ServeHTTP(0xc0006f6000, 0x1395ee0, 0xc00138c2a0, 0xc000d2ae00)
	/usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc00024dae0, 0x139b4e0, 0xc000f09c80)
	/usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2933 +0x35c
gin-gonic/gin

Answer questions aaronjheng

By the way,recovery middleware can help.

useful!

Related questions

Got "ambiguous import: found github.com/ugorji/go/codec in multiple modules" after upgraded to latest (1.3.1) hot 1
How to implement timeout middleware in gin? hot 1
Got "ambiguous import: found github.com/ugorji/go/codec in multiple modules" after upgraded to latest (1.3.1) hot 1
Set the cookie attribute “SameSite = None” hot 1
Got "ambiguous import: found github.com/ugorji/go/codec in multiple modules" after upgraded to latest (1.3.1) hot 1
source:https://uonfu.com/
Github User Rank List