由于导入内部软件包,无法获取要构建的存储库的分支 [英] Cannot get a fork of a repository to build due to importing internal packages

查看:43
本文介绍了由于导入内部软件包,无法获取要构建的存储库的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个存储库的分支(具体来说, github.com/ethereum/go-ethereum ),并尝试确保可以在派生开发之前构建主应用程序(cmd/geth).但是,由于上游源导入了内部软件包,因此该构建无法在我的fork中工作.

I have made a fork of a repository (specifically, github.com/ethereum/go-ethereum) and am trying to make sure that I can build the main application (cmd/geth) before developing on the fork. However, due to the upstream source importing internal packages, the build does not work in my fork.

我已经使用GOPATH和Go模块进行了尝试.在每种情况下,当我尝试运行go install github.com/<me>/go-ethereum/cmd/geth)时,都会出现以下错误:

I have tried this both using GOPATH and Go modules. In each case, when I try to run go install github.com/<me>/go-ethereum/cmd/geth) I get the following error:

cmd/geth/main.go:40:2: use of internal package github.com/ethereum/go-ethereum/internal/debug not allowed

在Go模块方法中,我尝试添加一个replace指令来代替使用我的fork:

In the Go module approach, I have tried adding a replace directive to use my fork instead:

replace github.com/ethereum/go-ethereum => github.com/<me>/go-ethereum master

但这会导致相同的错误.

But this leads to the same error.

如果有帮助,我很乐意提供更多信息(例如,生成输出),但是似乎缺少了一些直接的信息,而不是简单地将所有ethereum/go-ethereum/internal实例替换为<me>/go-ethereum/internal.

I am happy to provide more information (e.g., build output) if that would be helpful, but it seems like there is something straightforward that I am missing, rather than simply replacing all instances of ethereum/go-ethereum/internal with <me>/go-ethereum/internal.

推荐答案

默认情况下,GOPATH设置为$ HOME/gopath,并且您的存储库源代码位于$ GOPATH/github.com/user/repo(或$ GOPATH/bitbucket.org/user/repo).

By default, GOPATH is set to $HOME/gopath, and your repository source code is placed in $GOPATH/github.com/user/repo (or $GOPATH/bitbucket.org/user/repo).

在处理分叉存储库时,为了导入内部软件包,应将原始存储库的路径添加到转到导入路径.

When working on a forked repo, in order to import internal packages, the path of the original repo should be added to the go import path.

例如,在Travis-CI上,我的分叉存储库失败同样的问题(不允许使用内部软件包).因此,我只是在travis.yml中设置 go_import_path -它通过了.

As an example, on Travis-CI, my forked repo failed on the same problem (use of internal package not allowed). So I just set go_import_path in travis.yml - and it passed.

这篇关于由于导入内部软件包,无法获取要构建的存储库的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆