top | item 31483864

(no title)

legorobot | 3 years ago

I think the idea is `sql.NullString` can be used to have a SQL NULL still be an empty string in Go (just avoid checking the `Valid` field, or cast to string -- no check necessary).

It seems like the intent of a string pointer vs. `sql.NullString` is their goal with this type anyways[1]?

In practice I've used a string pointer when I need a nullable value, or enforce `NOT NULL` in the DB if we can't/don't want to handle null values. Use what works for you, and keep the DB and code's expectations in-sync.

[1]: https://groups.google.com/g/golang-nuts/c/vOTFu2SMNeA/m/GB5v...

discuss

order

No comments yet.