I am using gorilla schema to populate a struct based on a user's form submission. My struct contains sql.NullString
and I am currently getting the following error:
schema: converter not found for sql.NullString
How can I use sql.NullString
in a struct that I want to populate with gorilla schema?
I created a gist ( https://gist.github.com/carbocation/51b55297702c7d30d3ef ) that shows one way to approach this. You need to create a
schema.Converter
for each of the four types: sql.NullString, sql.NullBool, sql.NullInt64, and sql.NullFloat64.An example for sql.NullString:
Then register this with your
*schema.Decoder
(usually a package global, in this case namedd
):