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

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

golang sql.RawBytes要怎么樣轉換成實際類型的變量?

golang sql.RawBytes要怎么樣轉換成實際類型的變量?

Helenr 2019-02-06 12:50:48
cols, err := rows.Columns() // Remember to check err afterwards vals := make([]interface{}, len(cols))for i, _ := range cols {     vals[i] = new(sql.RawBytes) }for rows.Next() {     err = rows.Scan(vals...)     // Now you can check each element of vals for nil-ness,     // and you can use type introspection and type assertions     // to fetch the column into a typed variable. }官方原文鏈接官方的Demo是這樣寫的,最下面留了3行注釋:Now you can check each element of vals for nil-ness, and you can use type introspection and type assertions to fetch the column into a typed variable.請問這個use type introspection and type assertions to fetch the column into a typed variable到底要怎么實現?查了諸多資料都沒有找到答案。網上大部分說的都是(string)value強轉,可能這些說法都有些年代了,我現在這樣寫是不行的,會報錯。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1544 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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