英文:
how to import and use an external library into a go project
问题
你好!根据你的描述,你想在Go语言项目中使用外部库。首先,你可以通过在终端中运行以下命令来获取aerospike客户端库:
go get github.com/aerospike/aerospike-client-go
这将下载并安装该库到你的Go语言环境中。然后,在你的代码中,你可以使用import
语句将该库导入到你的解决方案中:
import "github.com/aerospike/aerospike-client-go"
这样你就可以在你的代码中使用该库提供的对象和功能了。希望这可以帮助到你!如果你还有其他问题,请随时提问。
英文:
I'm newbie to go lang and i created an hello project with intellij.
now I want to use external lib.
for example:
connect into aerospike using:
http://www.aerospike.com/docs/client/go/examples.html
what I don't understand is how to import it into solution.
I've run from the terminal the command:
go get github.com/aerospike/aerospike-client-go
but I don't see any result in the project and don't understand which object to use from my main method.
can you help?
答案1
得分: 7
go get
命令会将依赖项下载到你的$GOPATH目录中,在构建源代码时,go编译器可以从该目录访问它。现在,你只需要通过完整的包名导入该包,例如import github.com/aerospike/aerospike-client-go
。
英文:
The go get
command downloads the dependency to your $GOPATH dir from where it is accessible by the go compiler when building your sources. Now you simply have to import the package by its full name import github.com/aerospike/aerospike-client-go
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论