我的Godeps.json文件是否正确生成了?

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

Is my Godeps.json correctly generated?

问题

我正在尝试在Heroku上部署一个简单的Go语言服务器。我已经成功运行了它。但是我想知道我对godep的使用是否正确。

这是我生成的Godeps.json文件。

{
    "ImportPath": ".",
    "GoVersion": "go1.5",
    "Packages": [
        "./..."
    ],
    "Deps": [
        {
            "ImportPath": "github.com/kevinlg/trendee-api",
            "Rev": "6acde53081a273d4caedf113688e1ab83854c877"
        }
    ]
}

我想知道为什么"ImportPath"是".",而不是github.com/kevinlg/trendee-api,而将其作为依赖项?

当我查看Heroku示例或godep的Godeps.json文件时,我可以看到

"ImportPath": "github.com/heroku/go-getting-started",

或者

"ImportPath": "github.com/tools/godep"

我已经成功运行并部署了服务器在Heroku上。

这是我的项目文件夹结构

trendee-api /(GOPATH)
   bin/
   Godeps/
   pkg/
   src/
     github.com/
      kevinlg/
        trendee-api/

我使用了以下命令。

godep save -r ./...
go install github.com/kevinlg/trendee-api

提前感谢您的帮助。

英文:

I am trying to deploy a simple go lang server on heroku.I have managed to get it running. But I am wondering if my utilisation of godep is proper.

Here is the Godeps.json I have produced.

{
	"ImportPath": ".",
	"GoVersion": "go1.5",
	"Packages": [
		"./..."
	],
	"Deps": [
		{
			"ImportPath": "github.com/kevinlg/trendee-api",
			"Rev": "6acde53081a273d4caedf113688e1ab83854c877"
		}
	]
}

I am wondering why "ImportPath":"." and not github.com/kevinlg/trendee-api instead of having it as a dependency ?

When I check the Heroku example or the Godeps.json for godep I can see

"ImportPath": "github.com/heroku/go-getting-started",

or

"ImportPath": "github.com/tools/godep

I have been able to get the server running and deployed on heroku.

Here is my project folder structure

trendee-api /(GOPATH)
   bin/
   Godeps/
   pkg/
   src/
     github.com/
      kevinlg/
        trendee-api/

I have used the following commands.

godep save -r ./...
go install github.com/kevinlg/trendee-api

Thanks in advance for the help

答案1

得分: 1

当你使用godep save -r ./...命令时,你保存的是多个包,这就是为什么你的Godeps.json文件看起来是这样的。

对于单个二进制文件,你也可以在$GOPATH/src/github.com/kevinlg/trendee-api目录下使用godep save -r命令,前提是有以下的目录结构:

   bin/
   Godeps/
   pkg/
   src/
     github.com/
      kevinlg/
        trendee-api/
            main.go
英文:

When you use godep save -r ./... you are saving multiple packages, which is why your Godeps.json looks like that.

For a single binary, you could also use godep save -r in the $GOPATH/src/github.com/kevinlg/trendee-api directory, given the following structure:

   bin/
   Godeps/
   pkg/
   src/
     github.com/
      kevinlg/
        trendee-api/
            main.go

答案2

得分: 1

我是你的中文翻译助手,以下是翻译好的内容:

我刚开始学习Go语言,也遇到了Godeps的问题。
你为什么要使用"go install"命令?
你可以尝试使用这个链接,这是Heroku官方网站上关于Godeps的教程
实际上,你可以在命令行中使用"godep help save"来了解更多关于"godep save"的信息。

英文:

I'm new to go and I had problem with Godeps too.
why you are using "go install ".
try using this link,
this is the heroku's website teaching about Godeps

and actually you can use godep help save
in command line to learn more about "godep save"

huangapple
  • 本文由 发表于 2015年12月30日 17:17:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/34526431.html
匿名

发表评论

匿名网友

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

确定