# Go + FoundationDB - Straight Forward Steps

**URL:** <https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274>\
**Category:** Development\
**Tags:** bindings\
**Created:** [April 1, 2019, 9:02pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274 "2019-04-01T21:02:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravilution](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ravilution/32/728_2.png) [@ravilution](https://forums.foundationdb.org/u/ravilution)\
**Post date:** [April 1, 2019, 9:02pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/1 "2019-04-01T21:02:46Z")

</div>

Hi,

I am unable to set up **Foundation DB with Go bindings**. There is no straight forward way I could find or implement. Foundation DB is working clean. The steps are super simple. Not the same with Go Bindings. I tried both in my MacOS and in GitLab (AKA Docker). I was initially getting `FoundationDB error code 2203 (API version not supported)` error. Later I followed this [link](https://www.aarongreenlee.com/blog/fix-foundationdb-golang-binding-version-errors/). Now I get several other errors. Can you please share steps to make the Go Bindings (for FDB 6.0.18) work for those who are using go.mod approach.

Sincerely, Ravi

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [April 3, 2019, 4:02pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/2 "2019-04-03T16:02:16Z")

</div>

What errors are you seeing now?

Out go setup isn’t super idiomatic. This is for a few different reasons, including the fact that we use CGO (which a lot of other projects don’t), which requires some additional setup; the fact that we keep the go bindings in tree with the server and then basically ensure that the go bindings can talk to the server at the same (or actually a few related) git commit hashes, which means that using the default (i.e., master) version of the go bindings usually doesn’t work with the most recent release (which is older and often incompatible with the master branch); and because until recently, we required some things be auto-generated by the bindings, though now that’s checked in (though not always up to date).

There’s a script that _supposed_ to make this easier, though I’m not sure how well it does that: [https://github.com/apple/foundationdb/blob/master/bindings/go/fdb-go-install.sh](https://github.com/apple/foundationdb/blob/master/bindings/go/fdb-go-install.sh) I’m not sure if that works super well with go modules, though.

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [April 3, 2019, 4:03pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/3 "2019-04-03T16:03:11Z")

</div>

Oh, I guess see: [Installing bindings with Go modules](https://forums.foundationdb.org/t/installing-bindings-with-go-modules/1182)

---

<div class="post-metadata">

**Author:** ![meln1k](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/meln1k/32/150_2.png) [@meln1k](https://forums.foundationdb.org/u/meln1k)\
**Post date:** [April 3, 2019, 4:14pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/4 "2019-04-03T16:14:52Z")

</div>

I had a similar problem with go bindings from the master branch. I solved it by using [https://github.com/golang/dep](https://github.com/golang/dep) and explicitly setting the version in **Gopkg.toml**

```
[[constraint]]
  name = "github.com/apple/foundationdb"
  version = "6.0.18"
```

---

<div class="post-metadata">

**Author:** ![ravilution](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ravilution/32/728_2.png) [@ravilution](https://forums.foundationdb.org/u/ravilution)\
**Post date:** [April 5, 2019, 4:37pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/5 "2019-04-05T16:37:30Z")

</div>

Like I mentioned the error I get is

> `FoundationDB error code 2203 (API version not supported)`

---

<div class="post-metadata">

**Author:** ![ravilution](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ravilution/32/728_2.png) [@ravilution](https://forums.foundationdb.org/u/ravilution)\
**Post date:** [April 5, 2019, 4:38pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/6 "2019-04-05T16:38:21Z")

</div>

Can you share the steps from scratch you did? (for MacOS/Ubuntu/Linux)

---

<div class="post-metadata">

**Author:** ![ravilution](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ravilution/32/728_2.png) [@ravilution](https://forums.foundationdb.org/u/ravilution)\
**Post date:** [April 8, 2019, 1:09pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/7 "2019-04-08T13:09:15Z")

</div>

Finally, I solved it with below steps. Thanks to [Philidor Green](https://github.com/fishbullet)’s [Try FoundationDB Article](https://github.com/fishbullet/foundationdb). Below are the scripts.

```auto
apt-get update
apt-get install --fix-missing --yes wget dpkg python git mono-complete make default-jre m4
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-clients_6.0.18-1_amd64.deb
dpkg -i foundationdb-clients_6.0.18-1_amd64.deb
wget https://www.foundationdb.org/downloads/6.0.18/ubuntu/installers/foundationdb-server_6.0.18-1_amd64.deb
dpkg -i foundationdb-server_6.0.18-1_amd64.deb
wget https://raw.githubusercontent.com/apple/foundationdb/master/bindings/go/fdb-go-install.sh
chmod +x ./fdb-go-install.sh
./fdb-go-install.sh install --fdbver 6.0.18

```

_go.mod_

```go
module gitlab.com/ravilution/my-gitlab-example

go 1.12

require github.com/apple/foundationdb/bindings/go/src/fdb v6.0.18

```

---

<div class="post-metadata">

**Author:** ![ryanworl](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ryanworl/32/440_2.png) [@ryanworl](https://forums.foundationdb.org/u/ryanworl)\
**Post date:** [April 8, 2019, 10:01pm UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/8 "2019-04-08T22:01:55Z")

</div>

Unfortunately, this left me in the same place as I was before. Perhaps this is an issue with macOS or my setup specifically I am hitting.

EDIT:

I did notice that in my `GOPATH/pkg` directory where the Go modules system seems to store code, the path looks like this:

`../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20190408204346-47931674b55f/src/fdb/cluster.go:27:`

As of writing this, `47931674b55f` is a portion of the git hash of the current HEAD of master. This makes sense as to why I’m getting generated code for API version `610`.

Not sure what to do about that though.

EDIT 2:

I followed that procedure on a fresh Ubuntu 16.04 VM and same issue. Presumably I am at fault here if it worked for you though.

EDIT 3:

I went back to the original PR that added Go modules support and I just realized the `go.mod` file is not in the `6.0.18` tag at all. It was merged after 6.0.18 was tagged.

EDIT 4:

I proceeded to run my `go get` as `go get github.com/apple/foundationdb/bindings/go@release-6.0` It picked the git hash `f2d582ffa197` as you would expect. Once we get a new release in the 600 line or we all decide to move to 610 when it is available this should get easier.

---

<div class="post-metadata">

**Author:** ![alexmiller](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alexmiller/32/326_2.png) [@alexmiller](https://forums.foundationdb.org/u/alexmiller)\
**Post date:** [April 9, 2019, 6:37am UTC](https://forums.foundationdb.org/t/go-foundationdb-straight-forward-steps/1274/9 "2019-04-09T06:37:50Z")

</div>

> [@ryanworl](#):
>
> Once we get a new release in the 600 line or we all decide to move to 610 when it is available this should get easier.

Is all you need the head of release-6.0 to be tagged? Is using `release-6.0` fine until a version of 6.1 is declared stable?
