github - hyperledger-fabric-readthedocs.io 教程,开发人员的链代码,找不到包 shim - 已修复
问题描述
我在创建这篇文章时想出了解决这个问题的方法,但我想我会把我的眼泪留在这里,也许可以帮助遇到同样事情的其他人。最终问题的根源在于教程中的过时说明,没有反映对基础存储库的更改。
我正在从这个页面工作: https ://hyperledger-fabric.readthedocs.io/en/release-1.4/chaincode4ade.html
我的环境: - Ubuntu 18.04 服务器(在 virtualbox 中作为 VM 运行) - 转到版本 1.13.5 - 工作目录:/home/fabric-1/go/src/sacc - $GOPATH:/home/fabric-1/go
同样在 /home/fabric-1/go/src 我已经克隆了织物:
git clone https://github.com/hyperledger/fabric.git
在我的 ~/go/source/sacc 目录中,我根据说明使用以下导入编写了文件:
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/peer"
)
所以当我第一次运行命令时
go get -u github.com/hyperledger/fabric/core/chaincode/shim
我收到一条错误消息,指出它找不到包“shim”。我在 github.com 目录上执行了“查找”命令,发现它在那里,但是在一个奇怪的地方,我尝试将 shim 目录移动到某个友好的地方,这导致当你执行类似的操作时通常会出现兔子洞狂热那 ...
在花了一天的时间,尝试从其他地方安装 shim 代码之后,我终于意识到(呃!)更改 shim 的导入语句:
import (
"fmt"
"github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric/protos/peer"
)
在此之后,“go get”找到了,但“go build”失败了——找不到“peer”(叹气)
午休后(并抵制了喝伏特加酒的诱惑),我认为他们在编写教程后重新安排了一些事情。我仔细查看了路径,发现其他 github.com 目录下还有 github.com 目录。于是回到github(终于不怕了),找到对应子目录的repositories:
https://github.som/hyperledger/fabric/fabric-chaincode-go
https://github.som/hyperledger/fabric/fabric-protos-go
我将这些克隆到我的环境中:
cd $GOPATH/src/github.com/hyperledger
git clone https://github.som/hyperledger/fabric/fabric-chaincode-go
git clone https://github.som/hyperledger/fabric/fabric-protos-go
然后我再次返回并更改了 sacc.go 代码中的导入语句:
import (
"fmt"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-protos-go/peer"
)
嘿!是的!'go get' 和 'go build' 命令工作得很好,编译成功,现在开始下一个问题(好吧,好吧,实际上是明天 - 天很黑很冷,我想我会去做伏特加我之前没喝过)。
解决方案
我也在这个页面上工作。
go get -u github.com/hyperledger/fabric/core/chaincode/shim
运行命令时出现以下错误。
package github.com/hyperledger/fabric/core/chaincode/shim: cannot find package "github.com/hyperledger/fabric/core/chaincode/shim" in any of:
/usr/local/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOROOT)
/home/ubuntu/go/src/github.com/hyperledger/fabric/core/chaincode/shim (from $GOPATH)
我从 hyperledger github 页面搜索了“shim”目录,发现目录路径已更改。
然后,我更新了相关的sacc.go
文件行,如下所示:
import (
"fmt"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-protos-go/peer"
)
更新后,go get -u github.com/hyperledger/fabric-chaincode-go/shim
对go build
我来说工作得很好。
推荐阅读
- python - 将“正常”向量输入 MLP 并接收 *one* 输出值作为结果的正确方法是什么?
- google-apps-script - Google Scripts Concatenate Cells in different columns
- scala - 逐行读取数据集并将每个空格分隔的行转换为 Scala 中的逗号分隔
- elasticsearch - 如何在弹性搜索中处理自相交的 GeoJson 多边形
- sql - 从oracle中的json维度数组中获取值
- ios - 使用 swift 在 iOS 中使用 ChromeCast
- python - 使用绘图和导航栏生成 HTML
- sql - 从 SQL 中的字符串中获取第二个
- linux - 无法为 uclibc 交叉编译 dropbear
- wordpress - 为更新提供 wordpress SSH 访问权限是否安全?