Go importing vendor dependencies issue when building a Go 1.7 project using govendor, dh-make-golang

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

Go importing vendor dependencies issue when building a Go 1.7 project using govendor, dh-make-golang

问题

我一直在研究将一个Go项目构建成Debian软件包。

我已经研究了dh-make-golang,并在我的代码库中设置了一个漂亮而完整的debian文件夹。但是,当我尝试使用gbp buildpackage --git-pbuilder时,由于找不到所有的依赖项,它会报错。似乎dh-make-golang在从我的项目的Git仓库中复制所有内容时忽略了vendor文件夹,而我使用的是govendor,所以所有的依赖项都在那里。

我该如何解决这个依赖问题,并正确地构建项目为.deb软件包?供参考,我得到的错误是:

src/github.com/project/project/project.go:15:2: cannot find package "google.golang.org/grpc/grpclog" in any of: /usr/lib/go-1.7/src/google.golang.org/grpc/grpclog (from $GOROOT) /tmp/project/obj-x86_64-linux-gnu/src/google.golang.org/grpc/grpclog (from $GOPATH)

英文:

I've been looking into building a go project into a debian package.

I've looked into dh-make-golang and I have a nice and shiny debian folder set up in my repository. When I try to use gbp buildpackage --git-pbuilder though it errors out due to all of my dependencies not being found. It seems that dh-make-golang ignores the vendor folder when it copies everything from my project's git repository, and I use govendor so all of my dependencies are in there.

How can I resolve this dependency issue and build the project as a .deb package properly? For reference, the error I am getting is:

src/github.com/project/project/project.go:15:2: cannot find package "google.golang.org/grpc/grpclog" in any of:
/usr/lib/go-1.7/src/google.golang.org/grpc/grpclog (from $GOROOT)
/tmp/project/obj-x86_64-linux-gnu/src/google.golang.org/grpc/grpclog (from $GOPATH)

答案1

得分: 1

问题是关于dh-make-golang在导入供应商依赖项方面的一个错误。它刚刚在今天修复了。

https://github.com/Debian/dh-make-golang/issues/46

英文:

Issue was a bug in dh-make-golang regarding importing vendor dependencies. It was just fixed today.

https://github.com/Debian/dh-make-golang/issues/46

答案2

得分: 0

请看一下goxc - 它可以为您完成这个任务!

您只需要在您的目录根目录下添加一个名为.goxc.json的文件,内容如下:

{
    "AppName": "my_app",
    "ArtifactsDest": "downloads",
    "Tasks": [
        "interpolate-source",
        "deb"
    ],
    "BuildConstraints": "linux,amd64 windows,amd64 darwin,amd64 linux,arm",
    "ResourcesInclude": "INSTALL*,README*,LICENSE*,config/*,static/*,templates/*",
    "PackageVersion": "0.9.3",
    "TaskSettings": {
        "deb": {
            "metadata": {
                "description": "my app",
                "maintainer": "me",
                "maintainer-email": "me@example.com"
            },
            "metadata-deb": {
                "Homepage": "https://example.com"
            },
            "other-mapped-files": {
                "/": "debian/",
                "/usr/share/something/static": "static/",
                "/usr/share/something/templates": "templates/"
            }
        }
    },
    "ConfigVersion": "0.9"
}

然后运行goxc,它会为您完成所有的工作。

英文:

Take a look at goxc - it can do this for you!

You simply need to add a .goxc.json to the root of your directory, that looks like this

{
	"AppName": "my_app",
	"ArtifactsDest": "downloads",
	"Tasks": [
		"interpolate-source"
		"deb",
	],
	"BuildConstraints": "linux,amd64 windows,amd64 darwin,amd64 linux,arm",
	"ResourcesInclude": "INSTALL*,README*,LICENSE*,config/*,static/*,templates/*",
	"PackageVersion": "0.9.3",
	"TaskSettings": {
		"deb": {
			"metadata": {
				"description": "my app",
				"maintainer": "me",
				"maintainer-email": "me@example.com"
			},
			"metadata-deb": {
				"Homepage": "https://example.com"
			},
			"other-mapped-files": {
				"/": "debian/",
				"/usr/share/something/static": "static/",
				"/usr/share/something/templates": "templates/"
			}
		}
	},
	"ConfigVersion": "0.9"
}

Then run goxc and it'll do all the work for you.

huangapple
  • 本文由 发表于 2017年3月29日 12:52:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/43084647.html
匿名

发表评论

匿名网友

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

确定