英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论