Result: well, it works somehow. The problem is not actually recognizing whether a folder contains a BadgerDB, but whether it is currently opened by another process.
It works quite reliably under Windows, but not under Linux. Unfortunately, the test for the existence of the LOCK file is very unreliable. In our scenario, it happens again and again that the LOCK file is still there, even if the corresponding service has been dead for a long time. Opening the file with os.O_EXCL does not help under Linux. Moreover, in my opinion, it is not actually the task of the calling application to test access at file level to determine whether a database is in use or not. I think it would be better (and much more far-sighted) if this were part of the BadgerDB API, e.g. as badger.IsLocked(fs) and badger.IsDBPath(fs) or something similar.
Is there a possibility of implementing this as a feature?