我觉得这应该是一个小问题,但我已经尝试了我能想到的所有模式,但我没有任何运气。我有一个结构,需要由 theencoding/json和github.com/zeebo/bencode包编码。它恰好包含一个通道,该通道不能被任何一个包编码。因此,它需要携带标签"-",以便跳过该字段。
type Index struct {
Data data
Queue chan string `json:"-"`
}
这在由包编码时有效json,但在包中失败bencode。
type Index struct {
Data data
Queue chan string `bencode:"-"`
}
当然,这个块有互补的问题。我尝试过标签语法,如json:"-",bencode:"-", *:"-", "-", -. 有解决办法吗?
谢谢你们。