package main
import (
"fmt"
"github.com/go-ozzo/ozzo-dbx"
_ "github.com/go-sql-driver/mysql"
)
type DecimalDemo struct {
Id int
Amount float64
}
func main() {
db, _ := dbx.Open("mysql", "root:password@/test")
var a float64 = 0.0003
var b float64 = 0.0002
var c float64 = a - b
fmt.Println("c:", c)
var d float64 = a * b
demo := &DecimalDemo{
Id:0,
Amount:d,
}
db.Model(demo).Insert()
}
来源:oschina
链接:https://my.oschina.net/netflasher/blog/3160158