
1 btjoker 2018 年 3 月 12 日 因为你取到的是复制品啊 m := map[string]data { "x": data {"one"} } n := data {"two"} m[x] = n |
2 btjoker 2018 年 3 月 12 日 不好意思, 引号和逗号掉了 雨痕的 Go 学习笔记, 建议看看 |
3 fuxiaohei 2018 年 3 月 12 日 https://golang.org/ref/spec#Assignments Each left-hand side operand must be addressable, a map index expression, or (for = assignments only) the blank identifier. Operands may be parenthesized. https://golang.org/ref/spec#Address_operators For an operand x of type T, the address operation &x generates a pointer of type *T to x. The operand must be addressable, that is, either a variable, pointer indirection, or slice indexing operation; or a field selector of an addressable struct operand; or an array indexing operation of an addressable array. As an exception to the addressability requirement, x may also be a (possibly parenthesized) composite literal. If the evaluation of x would cause a run-time panic, then the evaluation of &x does too. 赋值的对象必须是 addressable,用 *T 吧 |
4 laike9m 2018 年 3 月 12 日 |
5 admirez OP 嗯,用*T 搞定了 |