[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go
|
From: |
Andrea Bolognani |
|
Subject: |
Re: [PATCH v2 04/11] qapi: golang: Generate qapi's alternate types in Go |
|
Date: |
Thu, 9 Nov 2023 09:34:56 -0800 |
On Mon, Oct 16, 2023 at 05:26:57PM +0200, Victor Toso wrote:
> [*] The exception for optional fields as default is to Types that can
> accept JSON Null as a value. For this case, we translate NULL to a
> member type called IsNull, which is boolean in Go. This will be
> explained better in the documentation patch of this series but the
> main rationale is around Marshaling to and from JSON and Go data
> structures.
>
> Example:
>
> qapi:
> | { 'alternate': 'StrOrNull',
> | 'data': { 's': 'str',
> | 'n': 'null' } }
>
> go:
> | type StrOrNull struct {
> | S *string
> | IsNull bool
> | }
We should call this Null instead of IsNull, and also make it a
pointer similarly to what I just suggested for union branches that
don't have additional data attached to them.
--
Andrea Bolognani / Red Hat / Virtualization