Skip to content

Getting the value of a union #997

@ianbarrere

Description

@ianbarrere

Once a union value is set, is it possible to get the value it was set to again as a "standard" type without marshalling to JSON?

I'm working with NetworkInstance_Protocol_Ospfv2_Area_Identifier_Union, which is a union of string and uint32. Let's say I set it like this:

ospf := &ocNetInst.NetworkInstance_Protocol_Ospfv2{}
area, _ := ospf.NewArea(ocNetInst.UnionUint32(10))

I would like to retrieve the value of area.Identifier as a uint32 of 10 elsewhere in my code, but nothing I try works, because this variable is of type NetworkInstance_Protocol_Ospfv2_Area_Identifier_Union, and I haven't found anything in ygot that will give us back the value. I am also relatively new to go, so I might be missing something obvious about converting values as well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions