Compare and Set with Badger?

I’m writing to ask whether there is a “compare and set” operator in Badger, or if there is an idiomatic way to implement one. Consider the following:

	txn := db.NewTransaction(true)
	txn.Set([]byte("a"), []byte("b"))

	txn2 := db.NewTransaction(true)
	txn2.Set([]byte("a"), []byte("c"))

	txn.Commit()
	txn2.Commit()

In this case, I might have two goroutines trying to update the value of “a”. With this setup, the last person to commit will overwrite any previous transactions in flight.

Ideally, I’d be able to have a “compare and set” operator to be able to say “only set the value of a if its current value is blank”. Is this possible with badger primitives?

I could use a lock in my go code - but really asking if there’s a more idiomatic to do this within badger itself.