I did this:

https://github.com/pitakill/go_api/blob/devel/person/person.go#L51

The important part is that the struct Person, use a pointer string in the 
fields that maybe/maybe not be null from the Database

On Wednesday, November 16, 2016 at 1:00:39 PM UTC-6, m...@ualberta.ca wrote:
>
> Has anyone found a better solution to this besides using the NullString 
> struct? personally not a fan of that as it requires me to separately handle 
> returned boolean values
>
> On Wednesday, March 25, 2015 at 12:53:40 PM UTC-4, Chris Kastorff wrote:
>>
>> I use *string with database/sql when I need a nullable TEXT-y field. 
>>
>> On 03/23/2015 07:49 PM, danm...@gmail.com wrote: 
>> > I echo this point. Why can't string be assigned to nil? Should I just 
>> > get used to using []byte? It just seems way to common to have a 
>> nullable 
>> > string field and way to cumbersome to have use a struct with an extra 
>> > bool every time I want a basic string. Has this changed since posting? 
>> > 
>> > 
>> > 
>> > On Friday, April 4, 2014 at 11:48:46 AM UTC-5, sati...@gmail.com 
>> wrote: 
>> > 
>> >     But why is this designed this way? I am very new to go and I 
>> believe 
>> >     there is a "nil" in go. Why isn't a NULL value from the database 
>> >     simply mapped to nil? It seems too cumbersome to deal with 
>> something 
>> >     as simple as a nil. Database admins prefer NULL over empty strings 
>> >     because they say it reduces the size of the database overall. 
>> > 
>> >     On Thursday, February 21, 2013 7:28:37 AM UTC-8, aiee wrote: 
>> > 
>> >         chris, Julien and Tor, thank you for the hint. 
>> > 
>> >         On Wed, 2013-02-20 at 13:41, Tor Langballe wrote: 
>> >         > Note that if you need to SELECT timestamps, use the NullTime 
>> >         provided in 
>> >         > the source in 
>> >         > github.com/bmizerany/pq <http://github.com/bmizerany/pq> 
>> >         > (or roll your own) 
>> >         > As there isn't any NullTime in the standard sql package. 
>> > 
>> >         Solution isn't perfect IMHO, but I can go with it. 
>> > 
>> >         -- 
>> >         Kind regards,  Milan 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> > Groups "golang-nuts" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> > an email to golang-nuts...@googlegroups.com 
>> > <mailto:golang-nuts+unsubscr...@googlegroups.com>. 
>> > For more options, visit https://groups.google.com/d/optout. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to