I think pointers are a good way to do it. An alternative is shown by the
sql-package:
https://godoc.org/database/sql#NullString
Though it kind of depends on what your serialization layer provides.

On Sat, Jul 23, 2016 at 3:02 AM, 'Mihai B' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Is it idiomatic to use pointers on optional fields? I'm developing a RPC
> API and many resources have optional fields. For example AWS SDK[0] seems
> to use pointers for all the parameters (received and returned) including
> the struct fields.  Is there any other way(i.e. best practice) to
> distinguish between zero and no value at all ?
>
> Mihai.
> [0]
> https://godoc.org/github.com/aws/aws-sdk-go/service/cloudfront#CacheBehavior
>
> --
> 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.
>

-- 
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