You are redeclaring the package type. When converting type, the conversion semantics is simply mytype(a) and conversion occurs if the rule that you mention is respected. I suppose that you need to have your own struct to store date, with a different name everything works. The package type is indeed inaccessible. It is used in the parameter list of the func that you call.
Regards, On Friday, July 1, 2016 at 9:06:30 AM UTC+2, mura wrote: > > Hi all, > > I confronted with a confusing problem regarding struct conversion. > > See https://play.golang.org/p/n6NfjsthHP > > The declarations of PrivateKey and PublicKey are copied from crypto/rsa, > but the code can not be compiled. > It can be compiled successfully if the embedded field PublicKey is > replaced with rsa.PublicKey > > According to the spec, two structs are convertible as long as their > underlying types are identical. > > Is this case my misunderstanding or just a bug (either in the compiler or > in the spec)? > > mura, > > Thanks > -- 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.