There might be a super simple answer to this, but as a newbie at Go, I'm having an issue.
I'm fetching some data from MSSQL and have set up some struct properties as null.String since the DB can contain null values.
Before json encoding the structs, I need to manipulate them a bit and need to do some simple if statements, like: if row.x == "y" { //do stuff } but since row.x has the type null.String, that comparison fails with:
mismatched types null.String and string
If I try to convert it to string first: var x = string(row.x), I get:
There might be a super simple answer to this, but as a newbie at Go, I'm having an issue.
I'm fetching some data from MSSQL and have set up some struct properties as
null.String
since the DB can contain null values.Before json encoding the structs, I need to manipulate them a bit and need to do some simple if statements, like:
if row.x == "y" { //do stuff }
but sincerow.x
has the typenull.String
, that comparison fails with:If I try to convert it to string first:
var x = string(row.x)
, I get:What is the best way to handle this?