An ASN.1 SEQUENCE OF or SET OF type is mapped to a Go slice. The general form is []<element type> where <element type> would be replaced with the Go type of the SEQUENCE OF element.
If an element in a SEQUENCE, SET, or CHOICE directly references a SEQUENCE OF or SET OF type, a slice type is generated inline. A separate type is not generated to be referenced by the element. For example, consider the following type definitions:
SeqOfInt ::= SEQUENCE OF INTEGER Seq ::= SEQUENCE { a SeqOfInt, b SEQUENCE OF BOOLEAN }
This results in the following Go types being generated:
type SeqOfInt []int64 type Seq struct { A SeqOfInt B []bool }
Note that a separate type is not generated for the inline SEQUENCE OF BOOLEAN, the bool slice is generated inline.
As with other constructed types, the <Type>
in
SEQUENCE OF Type
can be any ASN.1 type, including
constructed types. Therefore, it is possible to have a SEQUENCE OF SEQUENCE,
SEQUENCE OF CHOICE, etc.
In such cases, the compiler interally creates an ASN.1 type for the nested, constructed type. The format of the name for this type is as follows:
<ProdName>Element
In this definition, <ProdName>
refers to the
Go name of the production containing the SEQUENCE OF type.
For example, a simple (and very common) single level nested SEQUENCE OF construct might be as follows:
A ::= SEQUENCE OF SEQUENCE { a INTEGER, b BOOLEAN }
In this case, a type is generated for the element of the SEQUENCE OF production. Internally, this is transformed into the equivalent ASN.1:
A-element ::= SEQUENCE { a INTEGER, b BOOLEAN } A ::= SEQUENCE OF A-element
These types are then converted into the equivalent Go types using the standard mapping that was previously described.