我正在尝试解析 geth 中的以下类型数组以"查看内部"并获取信息,但无法弄清楚如何操作。
txs []*types.Transaction
此类型在 geth 的其他地方声明为
type Transaction struct {
data txdata
hash atomic.Value
size atomic.Value
from atomic.Value
}
我正在尝试使用以下循环访问数据,但我似乎无法访问这些值中的任何一个。
for _, tx := range *txs {
fmt.Println(fmt.Sprintf("transactions in this block - hash: %s and data: ", tx.hash))
}
谁能指出我正确的方向,如何访问内存位置中的数据
,即数组*types.Transaction
具有访问器方法:
func (tx *Transaction) Hash() common.Hash
func (tx *Transaction) Data() []byte
func (tx *Transaction) Nonce() uint64
func (tx *Transaction) To() *common.Address
(以及更多(
阅读包文档并学习 Go。小写字段名称未导出(私有(。