> On May 24, 2021, at 9:36 PM, Nick Rosbrook <rosbro...@gmail.com> wrote:
> 
> For structs that have a keyed union, e.g. DomainBuildInfo, the TypeUnion
> field must be exported so that package users can get/set the fields
> within. This means that users are aware of the existence of the
> interface type used in those fields (see [1]), so it is awkward that the
> interface itself is not exported. However, the single method within the
> interface must remain unexported so that users cannot mistakenly "implement"
> those interfaces.
> 
> Since there seems to be no reason to do otherwise, export the keyed
> union interface types.
> 
> [1] 
> https://pkg.go.dev/xenbits.xenproject.org/git-http/xen.git/tools/golang/xenlight?tab=doc#DeviceUsbdev
> 
> Signed-off-by: Nick Rosbrook <rosbro...@ainfosec.com>

Reviewed-by: George Dunlap <george.dun...@citrix.com>

I wonder if at some point we should add documentation to the definitions of 
specific union types, saying explicitly what union type it implements, and 
maybe what the Type field should be set to.  e.g.:

DeviceUsbdevTypeUnionHostdev implements the DeviceUsbdevTypeUnion interface.  
If DeviceUsbdev.TypeUnion is set to this type, DeviceUsbdev.Type should be set 
to UsbdevTypeHostdev.

Might be overkill tho.


Reply via email to