Open HeRaNO opened 2 weeks ago
refer to https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/json/
For the following code:
package main
import (
"context"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/app/server"
"github.com/cloudwego/hertz/pkg/common/utils"
"github.com/cloudwego/hertz/pkg/protocol/consts"
)
func main() {
h := server.Default(server.WithHostPorts(":12345"))
h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {
ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"})
})
h.Spin()
}
Compiling with Go 1.23-rc1:
go build -tags stdjson
and the error message is:
# github.com/bytedance/sonic/loader
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/funcdata.go:37:32: undefined: _func
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/funcdata.go:74:12: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/funcdata.go:77:18: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/funcdata.go:188:28: undefined: compilationUnit
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:27:22: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:29:26: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:34:27: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:36:36: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:46:21: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:50:22: undefined: moduledata
../go/pkg/mod/github.com/bytedance/sonic@v1.11.3/loader/stubs.go:50:22: too many errors
In addition, hertz also has linkname
used in protobuf codegen. I'm afraid it cannot compile under Go 1.23 even if we bypass sonic issue.
I found that we used sonic https://github.com/cloudwego/hertz/blob/develop/pkg/app/server/binding/internal/decoder/sonic_required.go here, but with a wrong(?) gjson
tag. Not sure whether we should change it to stdjson
.
@li-jin-gou Hi. The code above cannot be compiled under Go 1.23-rc1. Could you please take a look?
Describe the bug
Upstream JSON lib
sonic
is suffering fromlinkname
usage locking down. And it affects hertz according to reports.Originally posted by @xin-hao-awx in https://github.com/bytedance/sonic/issues/660#issuecomment-2190483847
Also can find more information at https://github.com/bytedance/sonic/issues/637
BTW,
linkname
is used in hertz, too. So maybe we need an investigation.To Reproduce
Expected behavior
No error should be presented.
Hertz version:
On
develop
branchEnvironment:
Additional context
We have an update PR (#1106 ) but idle for a time. I can compile a naive hertz project with Go 1.21, and it runs OK. Please consider bumping the PR status.