Golang database/sql/driver.NotNull type and ConvertValue function example
package database/sql/driver
NotNull is a type that implements ValueConverter by disallowing nil values but otherwise delegating to another ValueConverter.
Golang database/sql/driver.NotNull type usage and ConvertValue function example
type NotNull struct {
Converter ValueConverter
}
func (n NotNull) ConvertValue(v interface{}) (Value, error) {
if v == nil {
return nil, fmt.Errorf("nil value not allowed")
}
return n.Converter.ConvertValue(v)
}
References :
https://golang.org/src/pkg/database/sql/driver/types.go
http://golang.org/pkg/database/sql/driver/#NotNull
http://golang.org/pkg/database/sql/driver/#NotNull.ConvertValue
Advertisement
Something interesting
Tutorials
+16k Golang : Get sub string example
+17k Golang : Get number of CPU cores
+27.9k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+9.4k Golang : Launch Mac OS X Preview (or other OS) application from your program example
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+14.4k Golang : How to convert a number to words
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+6.9k Fix sudo yum hang problem with no output or error messages
+9.4k Golang : Create unique title slugs example
+25.5k Golang : Generate MD5 checksum of a file