A variable of type [][]Operation has that type and only that type. Your Concurrent and Sequential types are convertible to []Operation, and this is what happens in the assignment.
You can probably use interfaces to accomplish what you want. type Operator interface { Operations() []Operation } Make Concurrent and Sequential distinct types that both implement Operations() []Operation. This can be as simple as type Concurrent []Operation func (c Concurrent) Operations() []Operation { return c } Make your top level thing an []Operator. Use type switching or further interface methods as appropriate. //jb On 23 Nov 2017, at 00:39, Hein Meling <hein.mel...@gmail.com<mailto:hein.mel...@gmail.com>> wrote: I have code like this: type TestCase struct { Name string Description string OrderOp [][]Operation } type Concurrent []Operation type Sequential []Operation With the intent to do things like this: OrderOp: [][]Operation{ Concurrent{ {ID: "A", Name: "Read", ArgumentType: "ReadRequest", Value: ""}, {ID: "B", Name: "Write", ArgumentType: "Value", Value: "7"}, }, Sequential{ {ID: "C", Name: "Read", ArgumentType: "ReadRequest", Value: ""}, {ID: "D", Name: "Write", ArgumentType: "Value", Value: "8"}, }, } However, it seems that the OrderOp array do not preserve the type information, and I cannot use type assertion or reflect.TypeOf() to recover the types Concurrent and Sequential, that I intended to. For a full example, see link below. My question is: How can I best work around this problem?? (Preferably without adding a separate field in a struct to discriminate between concurrent and sequential.) https://github.com/selabhvl/cpnmbt/blob/master/rwregister/table_test.go Thanks, :) Hein -- 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<mailto: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.