Have a read of https://research.swtch.com/interfaces. There you'll see that the memory layout of int and interface{} are not the same. This means you can't just treat one as the other, which essentially is what you are asking for.
On Sun, 2020-02-23 at 01:12 -0800, Glen Huang wrote: > Hi, > > I have a function that accepts an argument of type > map[string]interface{}, and I also have a value of type > map[string]int. > > Currently it seems I can't directly pass the value to the function. > Is there anyway I can directly coerce it or a new value of the exact > matching type must be created? > > I find it quite surprising that you can directly assign any variables > to interface{} but not when they are both "scoped inside" a map or a > slice. Is the asymmetry by design? > > Regards > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/39f21b5a-12f1-4c9b-a64c-19bf98c24919%40googlegroups.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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/110c6d66109d97c3230e703d6f2aab258298d65d.camel%40kortschak.io.