Google Go 错误 - “无法输入”
在我的 Go 代码中,我想创建一个自定义数据类型的数组。我调用
Blocks=make(*BlockData, len(blocks))
并收到错误:
cannot make type *BlockData
我的类 BlockData 包含 uint64、int64、float32、string、[]byte、[]string 和 []*TransactionData 等字段类型。最后一个是指向我的另一个自定义类的指针数组。
我应该怎么做才能修复这个错误?
In my Go code I want to make an array of custom data type. I call
Blocks=make(*BlockData, len(blocks))
and I get error:
cannot make type *BlockData
my class BlockData contains such field types as uint64, int64, float32, string, []byte, []string and []*TransactionData. The last one is an array of pointers to another custom class of mine.
What should I do to fix this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
make()
用于创建切片、贴图和通道。制作切片时,类型名称前面必须有[]
。使用它来创建指向 BlockData 的指针切片。
请参阅 Go 语言规范了解更多信息。
make()
is used to create slices, maps and channels. The type name must have[]
before it when making a slice.Use this to make a slice of pointers to BlockData.
Read more in the Go language specification.
制作切片、贴图和通道
例如,
输出:
Making slices, maps and channels
For example,
Output: