golang 运行时报错:
# gorm.io/driver/postgres
C:\Users\Administrator\go\pkg\mod\gorm.io\driver\postgres@v1.2.2\migrator.go:337:24: cannot use column (type Column) as type gorm.ColumnType in append:
Column does not implement gorm.ColumnType (missing AutoIncrement method)
# gorm.io/driver/sqlserver
C:\Users\Administrator\go\pkg\mod\gorm.io\driver\sqlserver@v1.2.1\create.go:55:33: not enough arguments in call to field.ValueOf
have (reflect.Value)
want (context.Context, reflect.Value)
C:\Users\Administrator\go\pkg\mod\gorm.io\driver\sqlserver@v1.2.1\create.go:61:35: not enough arguments in call to field.ValueOf
have (reflect.Value)
want (context.Context, reflect.Value)
其实时casbinv2依赖了postgres和sqlserver包,实际上它也仅仅是判断了一下DB的类型,没真正用上,因为我用的是mysql呀。
但是很傻逼,他就会报错,查了一圈,其实是版本bug:
gorm.io/driver/postgres v1.2.2 // indirect
gorm.io/driver/sqlserver v1.2.1 // indirect
这里两个版本会由bug
升级一下:
gorm.io/driver/postgres v1.3.1 // indirect
gorm.io/driver/sqlserver v1.3.1 // indirect
升级了就报错了,好像第二次遇到go的依赖有这些bug了
博客讲述了在使用Go语言开发时遇到gorm.io库中postgres和sqlserver驱动的版本bug,导致编译错误。具体表现为接口不匹配的问题。作者发现这可能是由于casbin依赖了未使用的postgres和sqlserver包,但实际上项目使用的是mysql。解决方案是升级gorm.io/driver/postgres到v1.3.1和gorm.io/driver/sqlserver到v1.3.1,但升级后仍然报错。文章反映了Go依赖管理中可能存在的问题。
617





