Re: [go-nuts] Re: differentiate if a value was set or not

2020-10-23 Thread Marcin Romaszewicz
A concrete example of an "Optional" implementation in present in the sql package: https://golang.org/src/database/sql/sql.go?s=4943:5036#L178 In SQL, it's common to have "null" values be distinct from zero values, so the DB package has a struct with the value and a flag whether the value was

Re: [go-nuts] Re: differentiate if a value was set or not

2020-10-23 Thread Jesper Louis Andersen
On Fri, Oct 23, 2020 at 12:17 AM Ian Lance Taylor wrote: > So there are several possible approaches. I'm guessing you want one > that is more implicit, but as a general guideline Go tends to prefer > explicit code. > > I don't think there is a good implicit approach to this problem. If you have

[go-nuts] Re: differentiate if a value was set or not

2020-10-22 Thread Ian Lance Taylor
On Thu, Oct 22, 2020 at 1:19 PM Andrew wrote: > > I've finished the survey but want to add this: > Go can add something for library author to "differentiate if a value was set > or not internally", so that we can use plain Go type in the library. > > Here is a link to the problem: >