JSON编码一个零值嵌入式JSON.MARSHALER PANICS,您会认为这是一个bug吗?
恐慌:JSON编码一个零值嵌入式JSON.MARSHALER PANICS,您会认为这是一个bug吗?,json,go,interface,marshalling,Json,Go,Interface,Marshalling,恐慌: json.NewEncoder(os.Stdout).Encode(struct { M json.Marshaler }{}) 我想为我的接口明确声明它应该自行封送: panic: interface conversion: interface is nil, not json.Marshaler 你认为这是错误吗?如果没有,为什么不呢?有趣的问题,我看到了争论双方的优点。有趣的问题,我看到了争论双方的优点。 type thing interface { jso
json.NewEncoder(os.Stdout).Encode(struct {
M json.Marshaler
}{})
我想为我的接口明确声明它应该自行封送:
panic: interface conversion: interface is nil, not json.Marshaler
你认为这是错误吗?如果没有,为什么不呢?有趣的问题,我看到了争论双方的优点。有趣的问题,我看到了争论双方的优点。
type thing interface {
json.Marshaler
Type() string
....
}