go - 访问内存位置数组中的数据
问题描述
我正在尝试解析 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。小写字段名称未导出(私有)。
推荐阅读
- mysql - 如何对 MySql 中返回的最顶层行执行计算?
- makefile - 如何将目标文件复制到 Makefile 中的子文件夹?
- arrays - 从 tcl 中的数组中检索数字索引
- reactjs - 如何在我的反应组件中使用在 mongodb 上通过 multer 上传的图像?
- java - Android Popup Menu + Database 和查看更改问题
- c# - UWP 从 inkToolbarPenButton 中删除大小滑块
- arrays - 如何从 np.arange 中检索值?
- postgresql - 即使服务器关闭了连接,我的 PostgreSQL 查询是否仍在运行?
- excel - 索引匹配其他表中的数字,如果找不到,则匹配前 3 位数字
- r - 使用 tidymodels 编写分类工作流。得到“错误:列`.row`必须是长度..”