how to import and use an external library into a go project
Asked Answered
S

1

8

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?

Screwdriver answered 13/7, 2017 at 13:37 Comment(4)
Start with the example.Tanager
i just get package github.com/aerospike/aerospike-client-go/...: cannot download, $GOPATH must not be set to $GOROOT. For more details see: 'go help gopath'Screwdriver
Read How to write Go code.Tanager
Please add the error to the original question; don't make people read the comments to figure out what the actual problem is.Bircher
G
7

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

Georgetown answered 13/7, 2017 at 20:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.