Golang – 错误 `无法找到包`

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

Golang - error `cannot find package`

问题

在使用go get命令获取github.com/mattn/go-sqlite3时,我遇到了一个错误,错误信息是"golang.org/x/net/context"。

我不确定应该在哪里查找解决这个问题的方法。

英文:

After using go get to get on github.com/mattn/go-sqlite3 I get an error stating "golang.org/x/net/context".

I'm not sure as to where to look to resolve this issue

答案1

得分: 7

你是否已经下载了context包的源代码?

一种常见的方法是使用捆绑的工具go get,具体操作如下:

go get golang.org/x/net/context

这将把context包的源代码导入到你的Go工作空间中,Go工作空间由GOPATH环境变量定义。(在你的情况下,该包的代码将被下载到$GOPATH/src/golang.org/x/net/context。)

另外,你也可以对父包执行go get,以自动包含其所有依赖项,而无需逐个查找和下载它们。例如:

go get github.com/mattn/go-sqlite3
英文:

Did you download the source code for the context package?

One common way to do that is to use the bundled tool go get by doing:

go get golang.org/x/net/context

This should import the source code for the context package into your Go workspace which is defined by the GOPATH environment variable. (In your case the package's code will be downloaded to $GOPATH/src/golang.org/x/net/context.)

Alternatively you can do a go get on the parent package to include all of its dependencies automatically without needing to find and download them one at a time. For example:

go get github.com/mattn/go-sqlite3

答案2

得分: 0

前往你的 github.com/mattn/go-sqlite3 文件夹。
然后运行 go get ./... 命令,将所有依赖项安装到你的项目文件夹中。

由于你的项目依赖项应该来自 github,它将会将所有依赖项安装到 $GOPATH/src/github.com 目录下。

英文:

Go to you github.com/mattn/go-sqlite3 folder.
And run go get ./... to install all dependencies into your project folder.

As your project's dependencies should come from github It will install all the dependencies into $GOPATH/src/github.com

huangapple
  • 本文由 发表于 2016年12月29日 10:37:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/41372420.html
匿名

发表评论

匿名网友

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

确定