Go: reloading configuration on the fly - take two

This is a follow up, and perhaps a more in depth coverage to the previous article Go: reloading configuration on the fly. Several commentators pointed out that perhaps the example wasn’t as consise or correct as it should be, or that it was in general confusing. This was my fault as I originally meant to write a very quick article on the subject using a very similified version of an application I was writing. »

Go: reloading configuration on the fly - responding to HUP signal

Reloading your application’s configuration while it is running is a relatively easy task in Go. The only real worry is about providing concurrent access to your configuration object; and that is easily solved with the sync package’s sync.Mutex struct. When it is embedded into a struct anonymously it provides the Lock() and Unlock() methods which will protect against concurrent access. Our sample program consists of three core parts: Configuration management Main execution loop Signal handling Our demo program will list “files” that are available (for whatever purpose) to standard output. »