Go:运行从GitHub存储库中派生的Go项目时,“不允许使用内部软件包" [英] Go : 'use of internal package not allowed ' when running a Go project forked from a GitHub repository

查看:291
本文介绍了Go:运行从GitHub存储库中派生的Go项目时,“不允许使用内部软件包"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经习惯了Go,并试图了解它的工作原理.

I'm getting used to Go, and trying to understand how it works.

因此,我正尝试从原始存储库派生的Zoonoo/go-ethereum存储库中运行测试代码,

So I'm trying to run the test code from my repository zoonoo/go-ethereum, forked from the original repository ethereum/go-ethereum.

eth目录下运行go test .时,出现以下错误:

When I run go test . under the eth directory, I get the following error :

eth/api.go:37:2: use of internal package not allowed

eth/api.go的第37行如下:"github.com/ethereum/go-ethereum/internal/ethapi"

37th line of eth/api.go is as follows : "github.com/ethereum/go-ethereum/internal/ethapi"

这是否意味着在派生go存储库时,您必须更改代码中所有依赖项的路径才能运行代码?
Go软件包系统是否完全支持存储库派生?

Does this mean when you fork a go repository, you have to change the path of all dependencies within the code to run the code?
Does Go package system support repository fork at all?

推荐答案

另一个进行项目:

克隆叉子

如果您希望使用InfluxDB的fork,例如您自己的fork,则仍必须遵循上面的目录结构.但是,与其克隆主仓库,不如克隆你的fork.请按照以下步骤操作叉子:

Cloning a fork

If you wish to work with fork of InfluxDB, your own fork for example, you must still follow the directory structure above. But instead of cloning the main repo, instead clone your fork. Follow the steps below to work with a fork:

export GOPATH=$HOME/gocodez
mkdir -p $GOPATH/src/github.com/influxdb
cd $GOPATH/src/github.com/influxdb
git clone git@github.com:<username>/influxdb

必须保留目录结构$ GOPATH/src/github.com/influxdb,以便Go导入正常工作.

Retaining the directory structure $GOPATH/src/github.com/influxdb is necessary so that Go imports work correctly.

按您的项目替换InfluxDB名称/URL,同样的想法也适用.

Replace InfluxDB name/URL by your project, and the same idea applies.

在您的情况下,只有GitHub fork可以将您的贡献推回去,并从中发出Pull请求.
它不会用作go get的来源,因为这些软件包与您的GitHub的回购URL不匹配.

In your case, the GitHub fork is only there for you to push your contribution back to it, and to make Pull request from it.
It won't serve as a source for go get to work, since the packages wouldn't match your GitHub for repo URL.

这篇关于Go:运行从GitHub存储库中派生的Go项目时,“不允许使用内部软件包"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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