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
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+7.5k Gogland : Single File versus Go Application Run Configurations
+4.1k Javascript : Empty an array example
+10.1k Golang : Test a slice of integers for odd and even numbers
+6.5k Elasticsearch : Shutdown a local node
+6.9k Default cipher that OpenSSL used to encrypt a PEM file
+11k Golang : Generate random elements without repetition or duplicate
+5.3k Golang : Get FX sentiment from website example
+5.4k Golang *File points to a file or directory ?
+5.9k Unix/Linux : How to open tar.gz file ?
+18k Golang : How to log each HTTP request to your web server?
+9.2k Golang : Create and shuffle deck of cards example