你的問題你好,美好的一天系統規格最新高纖窗戶 11postgres我正在嘗試運行 AutoMigrate 但出現錯誤,一切正常,但自上周以來,當我運行代碼時出現以下錯誤。2021/12/30 13:17:56 ←[35mC:/personal/projects/uni-blog/src/database/connect.go:43←[0m←[31m[error] ←[0munsupported data type: &[]2021/12/30 13:17:56 ←[35mC:/personal/projects/uni-blog/src/database/connect.go:43←[0m←[31m[error] ←[0mfailed to parse value &models.Claims{RegisteredClaims:jwt.RegisteredClaims{Issuer:"", Subject:"", Audience:jwt.ClaimStrings(nil), ExpiresAt:<nil>, NotBefore:<nil>, IssuedAt:<nil>, ID:""}, ID:uuid.UUID{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, got error unsupported data type: &[]2021/12/30 13:17:56 ←[35mC:/Users/raliq/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:192←[0m←[31m[error] ←[0munsupported data type: &[]2021/12/30 13:17:56 ←[35mC:/Users/raliq/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:167←[0m←[31m[error] ←[0munsupported data type: &[]2021/12/30 13:17:56 ←[35mC:/Users/raliq/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:167←[0m←[31m[error] ←[0mfailed to parse value &models.Claims{RegisteredClaims:jwt.RegisteredClaims{Issuer:"", Subject:"", Audience:jwt.ClaimStrings(nil), ExpiresAt:<nil>, NotBefore:<nil>, IssuedAt:<nil>, ID:""}, ID:uuid.UUID{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}, got error unsupported data type: &[]2021/12/30 13:17:56 ←[35mC:/Users/raliq/go/pkg/mod/gorm.io/driver/[email protected]/migrator.go:167←[0m←[31m[error] ←[0munsupported data type: &[]Sorry couldn't migrate'...Database connection was successful...這是我的代碼和出現問題的模型,因為它遷移了用戶模型,然后卡在了聲明中
1 回答

慕妹3146593
TA貢獻1820條經驗 獲得超9個贊
沒有為切片類型(即 []string)實現 Scanner/Valuer 接口。因此,您可以使用https://pkg.go.dev/github.com/lib/pq中的 pq.StringArray 類型,而不是 jwt.RegisteredClaims 結構中的 []string 類型。您可以使用具有相同字段但使用 pq.StringArray 類型而不是 []string 的自定義結構。
- 1 回答
- 0 關注
- 579 瀏覽
添加回答
舉報
0/150
提交
取消