man 1 flock I have decided to build my own flock utility in golang. After creating a public git repo on bitbucket I started thinking about the details. (a) use stdlib only (b) keep it simple © offer a command line and a package.
Nothing new there, but then…
Now the question becomes; should I always have a lock file? Every time I run any application should I have a lock file? Should that lock file prevent multiple instances of THIS version of the tool or any version of the tool. Or should the lock file act as a sort of semaphore indicating that there is an application of this type running?
I ended up with a few choices:
$ myapp -pidlockfileUse the program name arg and the current pid.
$ myapp -buildlockfileUse the program name and CI build number.
$ myapp -lockfileUse the program name prevent multiple instances of the same application on the same machine
$ myapp -nolockfileDo not use a lock file.