golang 编译问题:gorm.io/plugin/dbresolver@v1.2.1/dbresolver.go:139:18: cannot use map[string]gorm.Stmt{} (value of type map[string]gorm.Stmt) as type map[string]*gorm.Stmt in struct literal

发布时间 2023-04-18 21:04:27作者: Lucky小黄人^_^

golang 执行 sh build 来编译项目时,发现了有报错 pkg/mod/gorm.io/plugin/dbresolver@v1.2.1/dbresolver.go:139:18: cannot use map[string]gorm.Stmt{} (value of type map[string]gorm.Stmt) as type map[string]*gorm.Stmt in struct literal

解决方案是:执行 go get gorm.io/plugin/dbresolver@latestgorm.io/plugin/dbresolver 升级到最新版本,然后执行 go mod tidy 更新下 go.mod

再次执行 sh build 应该就不报错了

参考:[Question] cannot use map[string]gorm.Stmt{}