hertz-examples icon indicating copy to clipboard operation
hertz-examples copied to clipboard

hertz_gorm demo无法运行

Open yibajianghudao opened this issue 10 months ago • 3 comments

Describe the bug

运行go build -o hertz_gorm之后报错:

# github.com/cloudwego/hertz-examples/bizdemo/hertz_gorm
link: github.com/bytedance/sonic/ast: invalid reference to encoding/json.safeSet

To Reproduce

Steps to reproduce the behavior:

  1. 克隆hertz-examples仓库
  2. cd /hertz-examples/bizdemo/hertz_gorm/
  3. docker-compose up
  4. go build -o hertz_gorm

Expected behavior

正常编译

Hertz version:

最新版

Additional context

可能是sonic的版本问题,参考

go.sum部分信息:

github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.8.1 h1:NqAHCaGaTzro0xMmnTCLUyRlbEP6r8MCA1cJUrH3Pu4=
github.com/bytedance/sonic v1.8.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=

我是新手,不知道怎么找是哪个包引用了sonic.

yibajianghudao avatar Jan 27 '25 14:01 yibajianghudao

运行go get github.com/bytedance/sonic@latest可以临时解决

yibajianghudao avatar Feb 03 '25 08:02 yibajianghudao

升级hertz版本或者sonic版本即可解决问题

GuangmingLuo avatar Feb 03 '25 09:02 GuangmingLuo

有兴趣可以提交下PR更新 hertz_gorm 的 go.mod 文件

GuangmingLuo avatar Feb 05 '25 02:02 GuangmingLuo