Installing bindings with Go modules

I’ve followed the instructions in the repo for installing the Go bindings:

I just cloned master fresh and did not change to any specific branch or tag.

./fdb-go-install.sh install --fdbver 6.0.18

That goes fine (or so it appears) and gives me the CGO flags for compiling.

I add the bindings to my imports, and then I tried to build and I get this compile error:

# github.com/apple/foundationdb/bindings/go/src/fdb
In file included from ../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20190222233508-fb9b5e05fda2/src/fdb/cluster.go:27:
/Users/ryanworl/go/src/github.com/apple/foundationdb/bindings/c/foundationdb/fdb_c.h:35:2: error: Requested API version requires a newer version of this header
#error Requested API version requires a newer version of this header
 ^
1 error generated.
/*

#define FDB_API_VERSION 610

#include <foundationdb/fdb_c.h>

*/

There’s the snippet from cluster.go in the bindings.

#if !defined(FDB_API_VERSION)

#error You must #define FDB_API_VERSION prior to including fdb_c.h (current version is 600)

#elif FDB_API_VERSION < 13

#error API version no longer supported (upgrade to 13)

#elif FDB_API_VERSION > 600

#error Requested API version requires a newer version of this header

#endif

There’s the relevant contents of fdb_c.h

You can see the mis-matched versions in the .h file vs what the generated go is expecting.

Now I know that if I bang my head against this enough I can figure it out since I’ve had to change the Node bindings a few times, but I feel like I’m missing something here.

Do the bindings just not work with Go modules right now?

Sorry about this. I’ve just made it so you can pass an optional header version override into fdb.setAPIVersion(version, header_version?) to get around this problem if you’re using a version of FDB older than what I’ve hardcoded for FDB_API_VERSION (currently 600). Eg, fdb.setAPIVersion(520, 520) works.

I still have no idea what the best practices should be.

1 Like

No, this wasn’t something that was your doing at all! I was adding features I needed for a project before you had a chance to get to them. Node bindings are great. :+1:

1 Like

By the way, is there any plans to make Go bindings embedded to the binary (without extended library)?

we use (go mod on)
go get github.com/apple/foundationdb/bindings/go@release-6.0
and install client
https://www.foundationdb.org/download/

2 Likes

Worked only if we set api version to 600 fdb.MustAPIVersion(600) . Setting it to 610 failed
because the client library installed is 6.0.18 which supports only 600. 610 can be used only when 6.1.x client libraries are installed(which is yet to be released.)