For my use case it is guaranteed to only have 1 instance of badger open at a given time. Knowing this, is it safe to set BypassLockGuard true? Also, can you please confirm that when running with BypassLockGuard set to true, the single badger instance can still be used concurrently when shared with multiple go routines.
Yes, if you are only ever going to have a single instance of Badger active at any time, making BypassLockGuard true is usually safe. This flag permits you to opt out of some of the locking within, potentially enhancing performance when you know there will be no concurrent access. But even when BypassLockGuard is true, Badger remains safe to use with multiple goroutines, provided you are only accessing the database in one instance at a time. Badger’s underlying structure is still concurrent-safe within one instance, so using it with multiple goroutines (provided each operation is contained to one goroutine at a time) should be okay. Just remember that BypassLockGuard doesn’t eliminate all concurrency protection, it simply disables some internal locks that are not required in your particular scenario.