DEV Community

Discussion on: A clean way to pass configs in a Go application

Collapse
ilyakaznacheev profile image
Ilya Kaznacheev Author

Usually, the configuration is attached to the executable file, i.e. main.go.

Another part of the project (it may be a package or a set of packages, internal packages or whatever) should receive the related configuration via its own public interface (factories, functions, etc.).

In productive projects, I create the main config structure, which includes substructures for different parts of the program, because it's useful. But for libraries and open-source projects, it's ok to define config structure inside each package or library to decrease coupling.