Go + FoundationDB - Straight Forward Steps

bindings

(Ravilution) #1

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. 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


(Alec Grieser) #2

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 I’m not sure if that works super well with go modules, though.


(Alec Grieser) #3

Oh, I guess see: Installing bindings with Go modules


(Nikita Melkozerov) #4

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

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

(Ravilution) #5

Like I mentioned the error I get is

FoundationDB error code 2203 (API version not supported)


(Ravilution) #6

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


(Ravilution) #7

Finally, I solved it with below steps. Thanks to Philidor Green’s Try FoundationDB Article. Below are the scripts.

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

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

go 1.12

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


(Ryan Worl) #8

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.


(Alex Miller) #9

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?