Open woshidama323 opened 3 years ago
./main.go:156:39: cannot use fn (type rpcserver.ImplementFullNode) as type rpcserver.FullNode in argument to rpcserver.FlutterHandler:
rpcserver.ImplementFullNode does not implement rpcserver.FullNode (TestHandler method has pointer receiver)
原因解释 [代码示例]()
一般想用reflect来获取数据的数据类型 比如
type CustomStruct struct {
}
func getTypeName(t interface{}) string {
rt := reflect.TypeOf(t).Elem()
return rt.Name()
}
getTypeName(CustomStruct)
这样会有编译错误,可以这么改
func getTypeName(t reflect.Type) string {
return t.Name()
}
// Calling it:
getTypeName(reflect.TypeOf(CustomStruct{}))
或者
t := reflect.TypeOf((*CustomStruct)(nil)).Elem()
fmt.Println(t.Name()) // Prints CustomStruct
./docgen-md "api/api_full.go" "FullNode" "api" "./api" > documentation/en/api-v1-unstable-methods.md
找同学: github账户 超过180天 https://verify.glif.io/
登录这个网站 授权 然后填写 给定的地址,这样可以获取更多的数据
### 1. 因为引用了filecoin工程中的wallet 库 所以需要引入一些依赖,但是ffi这个依赖需要独立编译
因为是rust 写的,golang这边需要cgo来调用
而ffi本身需要先编译出来比如filcrypto.pc这样可以被调用的库
### 1. extern下 git submodule add ffi库
### 2.进入目录运行./build.sh 会报错
[ERROR cargo_lipo] Failed to build "filcrypto" for "aarch64-apple-darwin": Executing "/Users/imac/.rustup/toolchains/nightly-2021-04-24-x86_64-apple-darwin/bin/cargo" "--color" "auto" "build" "-p" "filcrypto" "--target" "aarch64-apple-darwin" "--release" "--lib" "--no-default-features" "--features" "multicore-sdr,opencl" finished with error status: exit status: 101
### 3.
517 https_proxy=localhost:1089 brew info hwloc
518 LIBRARY_PATH=/opt/homebrew/lib LDFLAGS="-framework OpenCL" make clean
519 LIBRARY_PATH=/opt/homebrew/lib LDFLAGS="-framework OpenCL" make
#### 针对比较老一点的cpu 必要的环境变量
export CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
export CGO_CFLAGS="-D__BLST_PORTABLE__"
简介
golang实现接口有很多需要注意的地方
Why can't I assign any slice to an []interface{}
原因: []interface{} is not an interface! 长度不一样 []interface{} 占两个words 一个是类型,一个是内容或者指针 对于N长的数据总长是 N*2
如果非要用 可以这样
参考资料