英文:
Use a Go GitHub repo
问题
我已经安装、设置并运行了Go,并且按照这些说明进行了操作。我的工作空间的组织结构如下:
gocode/
    bin/
    pkg/
    src/
        github.com/
            my_username/
                hello/
                    hello.go
            anomalyzer/
                algorithms.go
                ...
                README.md
我想要开始使用来自GitHub上分叉的存储库lytics/anomalyzer中的Go代码。我已经分叉了该存储库,并在github.com/anomalyzer/目录下设置了一个本地克隆,就像上面显示的那样。但是从github.com/anomalyzer/目录下,我尝试运行go install,却收到了错误消息algorithms.go:5:2: cannot find package "github.com/drewlanenga/govector" in any of: ...(列出了我的GOPATH)。看起来我还需要克隆github.com/drewlanenga/govector,是吗?有没有一种自动获取所有包依赖项的方法?
英文:
I have Go installed, setup, and running hello world; I followed these directions. My workspace is organized as follows:
gocode/
    bin/
    pkg/
    src/
        github.com/
            my_username/
                hello/
                    hello.go
            anomalyzer/
                algorithms.go
                ...
                README.md
I would like to start using Go code from a forked GitHub repo, lytics/anomalyzer. How can I do this? I forked the repo and setup a local clone in github.com/anomalyzer/ as shown above. But from the github.com/anomalyzer/ dir I try go install and get the error message algorithms.go:5:2: cannot find package "github.com/drewlanenga/govector" in any of: ...(lists my GOPATH). It looks like I need to also clone the github.com/drewlanenga/govector, do I? Is there an automated way to get all the package dependencies?
答案1
得分: 2
要获取远程包,请运行go get命令。因为go get命令会自动获取依赖项,并且不会获取已经存在的包,所以你可以运行以下命令来获取所有设置,包括github.com/drewlanenga/govector包:
go get github.com/lytics/anomalyzer
英文:
To fetch remote packages, run the go get command. Because the go get command automatically fetches dependencies and does not fetch a package that already have have, you can run
go get github.com/lytics/anomalyzer 
to get everything setup including the github.com/drewlanenga/govector package.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论