Thanks :) திங்., 15 ஏப்., 2019, பிற்பகல் 4:20 அன்று, roger peppe <rogpe...@gmail.com> எழுதியது:
> The dynamic type conversion needs to specify the exact type that was put > into the interface (B in this case). > You can convert it back to A afterwards: > https://play.golang.org/p/jBRtR_8RloC > > On Mon, 15 Apr 2019 at 11:32, Sankar P <sankar.curios...@gmail.com> wrote: > >> Playground url: https://play.golang.org/p/tDT7xCJJ_XN >> >> திங்., 15 ஏப்., 2019, பிற்பகல் 4:01 அன்று, Sankar < >> sankar.curios...@gmail.com> எழுதியது: >> >>> I have the following go code: >>> >>> ``` >>> type A map[string]interface{} >>> type B map[string]interface{} >>> >>> func f(a A) { >>> fmt.Println(a) >>> } >>> >>> func main() { >>> var b B >>> b = make(map[string]interface{}) >>> i := interface{}(b) >>> f(i.(A)) >>> } >>> ``` >>> >>> This code panics when I try to convert the B instance to type A. What is >>> the right way to do the cast here ? >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "golang-nuts" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/golang-nuts/f3jarN-BgC0/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> golang-nuts+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> Sankar P >> http://psankar.blogspot.com >> >> -- >> 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. >> > -- Sankar P http://psankar.blogspot.com -- 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.