在func文字的参数中不能使用nil作为类型_Ctype_CFAllocatorRef

问题描述 投票:1回答:1

我正在运行下面的命令来安装用于执行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

go ethereum solidity go-ethereum
1个回答
0
投票

我也遇到过这个问题。对我来说,问题是我正在使用的Geth vs 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)
© www.soinside.com 2019 - 2024. All rights reserved.