登录
首页 >  Golang >  Go问答

无法在 func 文句的参数中使用 nil 作为 _Ctype_CFAllocatorRef 类型

来源:stackoverflow

时间:2024-03-20 18:48:27 469浏览 收藏

怎么入门Golang编程?需要学习哪些知识点?这是新手们刚接触编程时常见的问题;下面golang学习网就来给大家整理分享一些知识点,希望能够给初学者一些帮助。本篇文章就来介绍《无法在 func 文句的参数中使用 nil 作为 _Ctype_CFAllocatorRef 类型》,涉及到,有需要的可以收藏一下

问题内容

我正在运行下面的命令来安装用 go for solidity 编写的单元测试包。

go install ./cmd/abigen

但我收到这些错误:

# github.com/ethereum/go-ethereum/vendor/github.com/rjeczalik/notify
vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:51:216: cannot use nil as type _Ctype_CFAllocatorRef in argument to func literal
vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:165:47: cannot use nil as type _Ctype_CFAllocatorRef in argument to _Cfunc_CFStringCreateWithCStringNoCopy
vendor/github.com/rjeczalik/notify/watcher_fsevents_cgo.go:166:225: cannot use nil as type _Ctype_CFAllocatorRef in argument to func literal

go版本:go版本go1.11.4 darwin/amd64


解决方案


我也遇到过这个问题。对我来说,问题是我使用的 geth 与 go 的版本。您可能需要将 geth 升级到当前版本或至少版本 geth v1.8.16

https://github.com/ethereum/go-ethereum/issues/17751

但这对我来说不是一个选择,所以我找到了第二个解决方案。在这些代码行中,您将看到 nils,您不需要切换所有这些代码,但是如果您将指定的代码切换为 c.kcfallocatordefault ,它应该可以工作。下面是实际替换的示例。

51

var source = c.cfrunloopsourcecreate(c.kcfallocatordefault, 0, &c.cfrunloopsourcecontext{
    perform: (c.cfrunloopperformcallback)(c.gosource),
})

165

p := c.cfstringcreatewithcstringnocopy(c.kcfallocatordefault, c.cstring(s.path), c.kcfstringencodingutf8, c.kcfallocatordefault)

166

path := C.CFArrayCreate(C.kCFAllocatorDefault, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil)

以上就是《无法在 func 文句的参数中使用 nil 作为 _Ctype_CFAllocatorRef 类型》的详细内容,更多关于的资料请关注golang学习网公众号!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>