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
+4.6k JavaScript : Rounding number to decimal formats to display currency
+11k Golang : Replace a parameter's value inside a configuration file example
+9.7k Golang : Populate slice with sequential integers example
+13.3k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+13.2k Golang : How to calculate the distance between two coordinates using Haversine formula
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+11.6k Golang : Simple file scaning and remove virus example
+6.7k Golang : When to use make or new?
+8.4k Golang : Convert word to its plural form example
+36.3k Golang : Convert(cast) int64 to string
+25.7k Golang : How to write CSV data to file
+9.4k Golang : Find the length of big.Int variable example