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
+9.1k Golang : How to capture return values from goroutines?
+17k Golang : Covert map/slice/array to JSON or XML format
+36.3k Golang : How to split or chunking a file to smaller pieces?
+11.6k Golang : Convert(cast) float to int
+9.5k Golang : Detect Pascal, Kebab, Screaming Snake and Camel cases
+5.8k Golang : List all packages and search for certain package
+8.5k Golang : How to check variable or object type during runtime?
+18.7k Unmarshal/Load CSV record into struct in Go
+10.4k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+43.5k Golang : Get hardware information such as disk, memory and CPU usage
+18.4k Golang : How to remove certain lines from a file
+7.5k Golang : Create zip/ePub file without compression(use Store algorithm)