本文整理匯總了Golang中github.com/antonholmquist/jason.Object.GetFloat64Array方法的典型用法代碼示例。如果您正苦於以下問題:Golang Object.GetFloat64Array方法的具體用法?Golang Object.GetFloat64Array怎麽用?Golang Object.GetFloat64Array使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/antonholmquist/jason.Object
的用法示例。
在下文中一共展示了Object.GetFloat64Array方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Save
func Save(db *sqlite3.Conn, table string, uid string, obj *jason.Object) error {
handle_err := func(col string, e error) {
if e != nil {
logger.Error("Error inserting %v into %v: %v", col, table, e.Error())
}
}
err := db.Exec(fmt.Sprintf("insert or ignore into %v ( uid ) values (?)", table), uid)
handle_err("", err)
for k, v := range obj.Map() {
if k == "uid" {
continue
}
// Are we a string or a number?
if i, err := v.Int64(); err == nil {
err = db.Exec(fmt.Sprintf("update %v set %v = ? where uid = ?", table, k), i, uid)
handle_err(k, err)
}
if f, err := v.Float64(); err == nil {
err = db.Exec(fmt.Sprintf("update %v set %v = ? where uid = ?", table, k), f, uid)
handle_err(k, err)
}
if s, err := v.String(); err == nil {
err = db.Exec(fmt.Sprintf("update %v set %v = ? where uid = ?", table, k), s, uid)
handle_err(k, err)
}
if arr, err := obj.GetFloat64Array(k); err == nil {
s := fmt.Sprintf("%v", arr)
err = db.Exec(fmt.Sprintf("update %v set %v = ? where uid = ?", table, k), s, uid)
handle_err(k, err)
}
}
return err
}