本文整理匯總了Golang中github.com/lib/pq/hstore.Hstore.Scan方法的典型用法代碼示例。如果您正苦於以下問題:Golang Hstore.Scan方法的具體用法?Golang Hstore.Scan怎麽用?Golang Hstore.Scan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lib/pq/hstore.Hstore
的用法示例。
在下文中一共展示了Hstore.Scan方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Scan
// Scan implements the sql.Scanner interface.
func (cm *CommandMap) Scan(src interface{}) error {
h := hstore.Hstore{}
if err := h.Scan(src); err != nil {
return err
}
m := make(CommandMap)
for k, v := range h.Map {
m[ProcessType(k)] = Command(v.String)
}
*cm = m
return nil
}
示例2: Scan
// Scan implements the sql.Scanner interface.
func (v *Vars) Scan(src interface{}) error {
h := hstore.Hstore{}
if err := h.Scan(src); err != nil {
return err
}
vars := make(Vars)
for k, v := range h.Map {
// Go reuses the same address space for v, so &v.String would always
// return the same address
tmp := v.String
vars[Variable(k)] = &tmp
}
*v = vars
return nil
}
示例3: Scan
func (h *Hstore) Scan(value interface{}) error {
hstore := hstore.Hstore{}
if err := hstore.Scan(value); err != nil {
return err
}
if len(hstore.Map) == 0 {
return nil
}
*h = Hstore{}
for k := range hstore.Map {
if hstore.Map[k].Valid {
s := hstore.Map[k].String
(*h)[k] = &s
} else {
(*h)[k] = nil
}
}
return nil
}