'Build error in Go/Golang: Column does not implement gorm.ColumnType (missing AutoIncrement method)
I am facing this build error in Golang V1.17 intermittently.
# gorm.io/driver/mysql
../../../../pkg/mod/gorm.io/driver/[email protected]/migrator.go:224:24: cannot use column (type Column) as type gorm.ColumnType in append:
Column does not implement gorm.ColumnType (missing AutoIncrement method)
I have tried restarting, clearing cache on VS Code, deleting go.mod and go.sum, and what-not.
Is there a workaround or something?
Solution 1:[1]
my problem solved by installing mysql driver for gorm:
~ go get gorm.io/driver/mysql
Solution 2:[2]
This is followed by go-gorm/gorm
issue 5096 which includes:
I update the latest gorm module with the following command:
rm -rf go.mod go.sum go mod init "panel" # <== replace by your own project name go mod tidy go mod vendor
After running the error, the replacement version is fine.
go mod edit -require=gorm.io/driver/[email protected] go mod edit -require=gorm.io/[email protected] go mod vendor
Solution 3:[3]
I solve it by update all relative package?it works?
go get gorm.io/gorm
go get gorm.io/driver/mysql
go get gorm.io/driver/sqlserver
go get gorm.io/driver/postgres
go mod vendor
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Amirreza Saki |
Solution 2 | VonC |
Solution 3 | Eson Church |