在GitHub存储库中导入特定的软件包。

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

Import a specific package inside a GitHub repository

问题

意图

我打算导入这个包(子目录)以重用其中的方法和类型:

https://github.com/hemantasapkota/go-convexhull/tree/master/convexhull

它位于这个仓库中:

https://github.com/hemantasapkota/go-convexhull

尝试过的方法

我尝试导入整个仓库:

import (
	"github.com/hemantasapkota/go-convexhull"
)

但是 go get github.com/hemantasapkota/go-convexhull 报错了。因为 它的 main.go 文件 中包含了 import "github.com/hemantasapkota/glu",而这是一个私有仓库。

问题

我该如何只导入该仓库中的 convexhull 子目录下的包呢?我的意思是,我不需要它的 main.go 和它带来的麻烦。

当然,我可以将 convexhull 子目录/包的文件复制到我的项目中。但我正在寻找一种简单地从 GitHub 导入它的方法。有什么建议吗?

英文:

Intention

I intend to import exactly this package (subdirectory) to reuse its methods and types:

https://github.com/hemantasapkota/go-convexhull/tree/master/convexhull

Which is inside this repository:

https://github.com/hemantasapkota/go-convexhull

Tried

I tried to import the whole repository:

import (
	"github.com/hemantasapkota/go-convexhull"
)

But go get github.com/hemantasapkota/go-convexhull is throwing errors. Since its main.go file contains import "github.com/hemantasapkota/glu" which is a private repository.

Question

How can I import just the package convexhull inside a sub-directory of that repository? I mean, I don't need its main.go and its troubles.

Of course, I can copy over the files of convexhull sub-directory/package into my project. But I'm looking for a way to just simply import it from GitHub. Any idea?

答案1

得分: 0

这个是可以工作的:


import (
	"github.com/hemantasapkota/go-convexhull/convexhull"
)

然而,在构建时,我收到了这个错误,我需要找出原因:

构建错误:go test -c -o /tmp/__debug_bin930480706 -gcflags all=-N -l .
package printer/app/threed/detect/dental
	imports github.com/hemantasapkota/go-convexhull/convexhull
	imports github.com/go-gl/gl: build constraints exclude all Go files in /home/m3/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20190320180904-bf2b1f2f34d7 (exit status 1)
英文:

This worked:


import (
	"github.com/hemantasapkota/go-convexhull/convexhull"
)

However, when building, I received this error which I need to figure out:

Build Error: go test -c -o /tmp/__debug_bin930480706 -gcflags all=-N -l .
package printer/app/threed/detect/dental
	imports github.com/hemantasapkota/go-convexhull/convexhull
	imports github.com/go-gl/gl: build constraints exclude all Go files in /home/m3/go/pkg/mod/github.com/go-gl/gl@v0.0.0-20190320180904-bf2b1f2f34d7 (exit status 1)

huangapple
  • 本文由 发表于 2021年11月17日 15:01:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/70000092.html
匿名

发表评论

匿名网友

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

确定