Why not just create a wrapper struct? Something like: type Mixed struct{ A *A B *B }
And then just encode/decode that? On Tuesday, January 17, 2017 at 1:16:37 PM UTC-8, casp...@gmail.com wrote: > > I got two struct types encoded into bytes by gob, I want to decode the > bytes into a specific struct, is it possible without try all struct > types(maybe 3 or more struct types)? > > I want to decode bytes without specify which elem in mixedBytes is struct > A, and which is struct B. > This is the playground url: https://play.golang.org/p/F0Wp5eWdGu > > Is is possible to implement it by a map or something like this? > > var typesMap = map[string]reflect.Value{ > "A": reflect.ValueOf(A{}), > "B": reflect.ValueOf(B{}), > } > > > > -- 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.