It boils down to the meaning of interface{}. interface{} means interface{} and _not_ "any type". While you can assign anything to a variable of type interface{} this does not mean that a variable of type interface{} _is_ "any type". There is no "any type" type in Go.
V. On Sunday, 23 February 2020 10:12:27 UTC+1, 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/1fb4f089-672c-41fd-bd9d-e832d5f5541c%40googlegroups.com.