For files, it depends on your application. If you have only one goroutine writing file, you do not need to. If more than one, then it depends:
If you coordinate the various processes (programs), you can use flock (and probably it will not be fun).
If you coordinate several goroutines in your program, you can use mutexes , or you can see if you can re-organize the program, so that only one routine writes to a file and the rest send updates via channels.
For SQLite, I believe that the easiest way would be to simply open one sqlite connection and use it from different goroutines; although it supports several processes that open it immediately, and if your system does a lot of parallel reads, which can be faster (global locking is used for writing).
source share