尝试创建一个可以通过”go get”命令获取的go.tools本地代码库。

huangapple go评论82阅读模式
英文:

Trying to create a local repo of go.tools that is go get-able

问题

我已经为go cover工具添加了一个新的开关(-xml),用于生成一个可以被Atlassian Clover消费的XML文档,这样我们的go项目在bamboo构建时可以报告简单的覆盖率统计信息。我希望这个本地版本可以通过go get 在构建代理中访问。

以下是我尝试过的步骤:

然后基本上按照https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-ImportanexistingGitprojectintoStash中描述的导入现有git项目到stash的步骤进行操作。

如果我执行'rm -rf tools',然后执行'go get -d stash.example.com/scm/x/tools',我会得到"unrecognized import path stash.example.com/scm/x/tools"的错误。如果我输入'go get -d stash.example.com/scm/x/tools.git'(提供vcs提示给go get),它就可以工作,但生成的子目录名为'test.git'。在路径中提供vcs提示的替代方法是从stash服务器的html中返回一个标签,但我不知道如何创建它。

我应该补充说明的是,'cd $GOPATH/src/stash.example.com/scm/x' + 'git clone http://user@stash.example.com/scm/x/tools.git'会按预期创建tools子目录。

我必须将其托管在防火墙内部的本地服务器上,因此github不是一个选项。有什么建议吗?

英文:

I have added a new switch (-xml) to the go cover tool to generate an XML doc that is consumable by Atlassian clover so the bamboo builds of our go projects can report simple coverage statistics. I would like this local version to be accessible to the build agents using go get <importpath>.

These are the steps I've tried:

- setup $GOPATH
- created $GOPATH/src/stash.example.com/scm/x
- cd $GOPATH/src/stash.example.com/scm/x
- git clone --bare https://go.goolesource.com/tools

and then basically followed the steps for importing an existing git project into stash as described in https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-ImportanexistingGitprojectintoStash

If I then 'rm -rf tools' followed by 'go get -d stash.example.com/scm/x/tools' I get "unrecognized import path stash.example.com/scm/x/tools". It works if I type 'go get -d stash.example.com/scm/x/tools.git' (providing the vcs hint to go get), but the resulting subdirectory is named 'test.git'. The alternative to providing the vcs hint in the path is to return a <meta> tag in the html from the stash server, but I have no idea how to create that.

I should add that 'cd $GOPATH/src/stash.example.com/scm/x' + 'git clone http://user@stash.example.com/scm/x/tools.git' creates the tools subdirectory as expected.

I must host this on a local server inside my firewall, so github is not an option. Any advice?

答案1

得分: 1

curl http://stash.example.com/scm/x/tools 会返回什么?有哪些服务器正在监听 stash.example.com?通常,一个可以使用 go get 的路径要么包含一个带有后缀的组件,后缀表示所使用的版本控制系统(例如 example.com/repository.git/package),要么在其中一个目录层中存在一个特定的元标签,告诉 go get 从哪里获取源代码。

go get 是一个简单的机制,如果我记得没错的话,当服务器需要身份验证时,它不能与 git 一起使用。

在这里查看有关如何使用 go get 的导入路径的相关文档。我不会引用这个文档,因为它相当长,不太可能消失,并且您可以通过安装 godoc 并运行以下命令在本地机器上检索它:

godoc -http=:8080 # 或其他端口

然后将浏览器指向:

http://localhost:8080/cmd/go/#hdr-Relative_import_paths.
英文:

What does curl http://stash.example.com/scm/x/tools yield? What servers are listening on stash.example.com? Generally, a go get-able path either contains a component with a suffix denoting the revision control system used (e.g. example.com/repository.git/package) or a certain meta-tag exists in one of the directory layers that tells go get where to get the source.

go get is an unsophisticated mechanism and if I recall correctly it doesn't work with git when the server requires authentication.

Have a look here for the relevant documentation on how import paths work with go get. I'm not going to cite out of this as it's rather long, unlikely to go down and you can retrieve it on your local machine by installing godoc and running

godoc -http=:8080 # or some other port

and then pointing your browser to

http://localhost:8080/cmd/go/#hdr-Relative_import_paths.

huangapple
  • 本文由 发表于 2015年1月7日 05:24:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/27807413.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定