db
db copied to clipboard
sql: Scan error on column index 1, name "com_name": converting NULL to string is unsupported
type Company struct {
Id string db:"id" form:"id" json:"id"
ComDesc string db:"com_desc,omitempty" form:"com_desc" json:"com_desc"
ComName string db:"com_name" form:"com_name" json:"com_name"
}
i use the omitempty tag ,that is not work
Please consider asking questions on Stack Overflow.
Or Golang Slack.
Either make sure the query doesn't return rows with com_desc = null or make use of sql.NullString like so:
type Company struct {
Id string `db:"id" form:"id" json:"id"`
ComDesc sql.NullString `db:"com_desc,omitempty" form:"com_desc" json:"com_desc"`
ComName string `db:"com_name" form:"com_name" json:"com_name"`
}