Golang Errors finding github.com/apple/foundationdb/bindings/go/src/fdb

Hi,

I am configuring my local environment on Windows 11 with WSL2 and Ubuntu.

I have installed foundationdb-client. I found some issues reported here

$ dpkg --status foundationdb-clients
Package: foundationdb-clients
Status: install ok installed
Priority: optional
Section: database
Installed-Size: 164663
Maintainer: The FoundationDB Community
Architecture: amd64
Version: 7.1.35
Depends: adduser, libc6 (>= 2.12)
Description: FoundationDB is a scalable, fault-tolerant, ordered key-value store with full ACID transactions.
 FoundationDB is a scalable, fault-tolerant, ordered key-value store
 with full ACID transactions.
 .
Homepage: https://www.foundationdb.org

And fdb bindings in go seem to be there after running go get:

$ go list  github.com/apple
/foundationdb/bindings/go/src/fdb
github.com/apple/foundationdb/bindings/go/src/fdb

I have also tried to install the bindings as explained here

$ ./fdb-go-install.sh install --fdbver 7.1.35
mkdir -p /home/manufog/go/src/github.com/apple
Downloading foundation repository into /home/manufog/go/src/github.com/apple:
git -C /home/manufog/go/src/github.com/apple clone --branch 7.1.35 https://github.com/apple/foundationdb.git
Cloning into 'foundationdb'...
remote: Enumerating objects: 217837, done.
remote: Counting objects: 100% (415/415), done.
remote: Compressing objects: 100% (255/255), done.
remote: Total 217837 (delta 228), reused 265 (delta 140), pack-reused 217422
Receiving objects: 100% (217837/217837), 164.18 MiB | 22.43 MiB/s, done.
Resolving deltas: 100% (172206/172206), done.
Note: switching to '335cdd51d43b28dd88119276d8a192b53044e761'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Building generated files.
make -C /home/manufog/go/src/github.com/apple/foundationdb bindings/c/foundationdb/fdb_c_options.g.h
make: Entering directory '/home/manufog/go/src/github.com/apple/foundationdb'
make: *** No rule to make target 'bindings/c/foundationdb/fdb_c_options.g.h'.  Stop.
make: Leaving directory '/home/manufog/go/src/github.com/apple/foundationdb'
Could not generate required c header

But for some reason it looks like go cannot find the bindings module :thinking:

go build -ldflags="-s -w -X github.com/FoundationDB/fdb-kubernetes-operator/setup.operatorVersion=4bcf4695bc8033ecffa7589cb0f41f832bf06a4b" -o bin/manager main.go
# github.com/apple/foundationdb/bindings/go/src/fdb
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/keyselector.go:39:10: undefined: KeyConvertible
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:31:8: undefined: Key
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:76:29: undefined: KeyConvertible
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:89:8: undefined: KeyConvertible
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:92:6: undefined: KeyConvertible
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:123:12: undefined: transaction
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:127:12: undefined: futureKeyValueArray
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:195:13: undefined: transaction
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/range.go:196:13: undefined: futureKeyValueArray
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/snapshot.go:33:3: undefined: transaction
../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/snapshot.go:33:3: too many errors
make: *** [Makefile:112: bin/manager] Error 1

Do these errors ring any bells? Any help to get this fixed would be greatly appreciated :pray:

Ok looks like ubuntu default installation was missing libc6 and cmake.

After installing both I am getting this error:

$ make manager
go build -ldflags="-s -w -X github.com/FoundationDB/fdb-kubernetes-operator/setup.operatorVersion=4bcf4695bc8033ecffa7589cb0f41f832bf06a4b" -o bin/manager main.go
# github.com/apple/foundationdb/bindings/go/src/fdb
In file included from ../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20230826033220-30d4f0739505/src/fdb/database.go:26:
/usr/include/foundationdb/fdb_c.h:34:2: error: #error Requested API version requires a newer version of this header
   34 | #error Requested API version requires a newer version of this header
      |  ^~~~~
make: *** [Makefile:112: bin/manager] Error 1

ok restoring go.mod and go.sum fixed it. Looks like I polluted the mod files during the troubleshooting.

Successful execution:

$ make manager
go build -ldflags="-s -w -X github.com/FoundationDB/fdb-kubernetes-operator/setup.operatorVersion=4bcf4695bc8033ecffa7589cb0f41f832bf06a4b" -o bin/manager main.go