I am glad I could help :) CHOICE would be nice, but I don't think it will happen (I don't have a source for this claim), but it is easy enough to unmarshal something to a asn1.RawValue and switch on the Tag field. If you want to know how to use the golang's asn1 library efficently you could have a look at the certificate parsing code in the x509 package.
Also, I would suggest that you should look at https://godoc.org/golang.org/x/crypto/cryptobyte. It is maintained by the go team. It could be easier to use cryptobyte to unmarshal complex structures. W dniu poniedziałek, 2 kwietnia 2018 04:18:31 UTC+1 użytkownik andrey mirtchovski napisał: > > Thanks for your help. I think I understood the problem I was having. > In the original code (not the example in this email) things that would > normally go to a CHOICE field were marshalled into a RawValue, which > then got switched on RawValue.Tag to decide where to go (it's part of > the protocol, unrelated to asn.1). That raw value consumed a tag, but > the subsequent structs that were supposed to be unmarshalled from that > did not expect that tag to be consumed. > > In the end my solution came down to calling > asn1.UnmarshalWithParams("tag:X") on the RawValue's FullBytes instead > of Bytes. > > I hope we get support for CHOICE some day. I fear my understanding for > asn.1 is becoming sufficiently (in)adequate that I may soon be tempted > to do my own unmarshaller for our special case data... > -- 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.