跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • go struct 里用什么类型来处理 mysql 的 decimal 类型的值
未分類
28 11 月 2020

go struct 里用什么类型来处理 mysql 的 decimal 类型的值

go struct 里用什么类型来处理 mysql 的 decimal 类型的值

資深大佬 : lalawac 0

报错 Scan error on column index 4, name “money”: converting driver.Value type []uint8 (“0.100”) to a int: invalid syntax

type Order struct{  Id    int     `"db:"id"`  Money float32 `"db:money"` }   var order Order  rows, err = DB.Query("select money from order where id =1") rows.Scan(&order.Money) 

google 了半天,尝试了几种 decimal 类型仍然不行,

大佬有話說 (2)

  • 資深大佬 : rimutuyuan

    这个或许有用
    https://github.com/shopspring/decimal

  • 主 資深大佬 : lalawac

    @rimutuyuan 谢谢, 搞定了

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具