// The nil pointer exception is not strictly necessary
// but mimics a similar, necessary exception in the behavior of
// UnmarshalJSON.
我英文水平有问题吗?翻译如下: 空指针异常不是必要的,但它在UnmarshalJSON的行为中模仿了一个相似的,必要的异常。 我怎么感觉不通顺呢?也没法理解。// An anonymous struct field of interface type is treated the same as having
// that type as its name, rather than being anonymous.
interface类型的匿名字段?这是允许存在的吗?
有疑问加站长微信联系(非本文作者)

来个大佬教教我吧
你都看源码包了,你才是大佬
大概的意思应该指的是: 1 json.Marshal 遇到空指针不会抛出异常,你可以看源码对空指针写的是 null,但是反序列化时空指针是会抛出异常的 2 json.Marshal 必须具名,否则用其类型作为名称
第一点我看源码时确实发现了它是这样子的,我总感觉它的英文描述不对劲。第二点也是,他要是不提interface我就没有问题了。
第二句我感觉说的是结构体嵌入?
这里的 B 有一个匿名字段,该字段名默认为和它的类型相同,因此名称为 A </br> anonymous 修饰的是 filed 的吧? 但是 interface 类型的结构体字段是什么意思,指的是 A 是一个接口类型?