[英]Issue in installing a go package
So,I recently started following a video tutorial and i am fairly new to golang and tried installing the forked version of bolt db using $ go get go.etcd.io/bbolt/... Note : I want to use this specific version but i am getting an error which says所以,我最近开始关注一个视频教程,我对 golang 还很陌生,并尝试使用 $ go get go.etcd.io/bbolt/...我收到一个错误,上面写着
go: go.mod file not found in current directory or any parent directory.
'go get' is no longer supported outside a module.
To build and install a command, use 'go install' with a version,
like 'go install example.com/cmd@latest'
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'
I read a few GitHub issues which say that go get is deprecated so how do I resolve this ?我阅读了一些 GitHub 问题,这些问题说 go get 已被弃用,那么我该如何解决这个问题? I also tried few other things such as go install go.etcd.io/bbolt/...我还尝试了其他一些东西,例如 go install go.etcd.io/bbolt/...
Go modules are today's standard. Go 模块是当今的标准。 Especially if you are new to Go;特别是如果您是 Go 新手; do not spend time on material that do not use (and teach) them.不要花时间在不使用(和教授)它们的材料上。
Run go mod init yourproject
in your project repository root directory.在项目存储库根目录中运行go mod init yourproject
。 This will create go.mod
file.这将创建go.mod
文件。
Once you have that you can either:一旦你有了它,你可以:
import go.etcd.io/bbolt
in source code and then run go mod tidy
.在源代码中import go.etcd.io/bbolt
然后运行go mod tidy
。 Go tool will find and add module to your dependencies ( go.mod
file). Go 工具会找到并添加模块到你的依赖项( go.mod
文件)。 This is described in Getting started tutorial.这在入门教程中进行了描述。go get go.etcd.io/bbolt
directly, that will update dependencies too.直接运行go get go.etcd.io/bbolt
,也会更新依赖。Using Go Modules series explains workflow in detail and will be helpful when converting commands from an outdated material.使用 Go Modules系列详细解释了工作流程,在从过时的材料转换命令时会很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.