...

Command flock

flock.go is a minimal implementation of flock(1) (from util-linux) for systems that don't have flock(1) but do have flock(2).

According to the Linux "man-pages"1 flock(2) documentation:

CONFORMING TO
       4.4BSD (the flock() call first appeared in 4.2BSD).  A
       version of flock(), possibly implemented in terms of
       fcntl(2), appears on most UNIX systems.

At the very least, macOS has flock(2).

No, BSD/macOS shlock(1) is not an accepable substitute. It is the opposite of robust.