本文整理汇总了Golang中database/sql/driver.Valuer类的典型用法代码示例。如果您正苦于以下问题:Golang Valuer类的具体用法?Golang Valuer怎么用?Golang Valuer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Valuer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: appendDriverValuer
func appendDriverValuer(b []byte, v driver.Valuer, quote bool) []byte {
value, err := v.Value()
if err != nil {
panic(err)
}
return Append(b, value, quote)
}
示例2: appendDriverValueRaw
func appendDriverValueRaw(dst []byte, v driver.Valuer) []byte {
value, err := v.Value()
if err != nil {
log.Printf("%#v value failed: %s", v, err)
return nil
}
return appendIfaceRaw(dst, value)
}
示例3: callValuerValue
// callValuerValue returns vr.Value(), with one exception:
// If vr.Value is an auto-generated method on a pointer type and the
// pointer is nil, it would panic at runtime in the panicwrap
// method. Treat it like nil instead.
// Issue 8415.
//
// This is so people can implement driver.Value on value types and
// still use nil pointers to those types to mean nil/NULL, just like
// string/*string.
//
// This function is mirrored in the database/sql/driver package.
func callValuerValue(vr driver.Valuer) (v driver.Value, err error) {
if rv := reflect.ValueOf(vr); rv.Kind() == reflect.Ptr &&
rv.IsNil() &&
rv.Type().Elem().Implements(valuerReflectType) {
return nil, nil
}
return vr.Value()
}
示例4: appendDriverValuer
func appendDriverValuer(dst []byte, v driver.Valuer) []byte {
value, err := v.Value()
if err != nil {
log.Printf("%T value failed: %s", v, err)
return appendNull(dst)
}
return appendIface(dst, value)
}
示例5: appendDriverValuer
func appendDriverValuer(b []byte, v driver.Valuer, quote bool) []byte {
value, err := v.Value()
if err != nil {
log.Printf("%T value failed: %s", v, err)
return appendNull(b, quote)
}
return appendIface(b, value, quote)
}