apple / foundationdb

FoundationDB - the open source, distributed, transactional key-value store
https://apple.github.io/foundationdb/
Apache License 2.0
14.33k stars 1.3k forks source link

golang: Transact can return nil? #4275

Open johscheuer opened 3 years ago

johscheuer commented 3 years ago

We ran in a pretty weird issue where we use golang and client.database.Transact which could result in a nil as return value (https://github.com/FoundationDB/fdb-kubernetes-operator/pull/478). In the actual method we always return a boolean value (https://github.com/FoundationDB/fdb-kubernetes-operator/blob/master/controllers/lock_client.go#L84-L140) I couldn't find any notice about this behaviour in the docs https://pkg.go.dev/github.com/apple/foundationdb/bindings/go/src/fdb. So I just wanted to ask if we hit a strange error or if this iss just a behaviour that should be documented?

I mean the simple example suggest that there is no need to check for nil: https://pkg.go.dev/github.com/apple/foundationdb/bindings/go/src/fdb#hdr-Basic_Usage

brownleej commented 3 years ago

It may be that in that example it's not necessary to check if ret is nil because it's explicitly checking if err is not nil. Still, it's probably best to get that contract documented.