The usage of structs it’s key in every Golang project. If we are team for several developers that work in the same repository we might face a lot of git conflicts. This is due to the code style that Golang uses where all the types of a struct needs to be aligned.

Her an example of a dependency container struct:

type Services struct {
	CommandBus command.Bus
	QueryBus   query.Bus
	Logger     logger.Logger
  ...
}

When a developer adds a new options might trigger a reformat that would affect all the lines of the struct so that developer would commit a change affecting many lines.

To avoid that in our team in Wallbox we started grouping the structs by type to minimize this situation.

For example we might have something like:

type Services struct {
	CommandBus command.Bus
	QueryBus   query.Bus

	Logger logger.Logger
}

Of course having big struct could be considered a bad smell so try to keep them as small as possible.

For example we have a services struct by each module of the application so each one is more focused and small.