亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

得到錯誤不支持的數據類型:&[]。這是 gorm 模型 + golang/jwt

得到錯誤不支持的數據類型:&[]。這是 gorm 模型 + golang/jwt

Go
蝴蝶不菲 2022-10-24 09:43:34
你的問題你好,美好的一天系統規格最新高纖窗戶 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 的自定義結構。



查看完整回答
反對 回復 2022-10-24
  • 1 回答
  • 0 關注
  • 579 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號