Pass common object to nested structs

My implementation now looks like this. The

c := NewFooConfig()
c.Logger = localLogger

is overkill right now as we only have a single field in the config and could be simplified by

c := FooConfig{Logger: localLogger}

However, this is not future-proof if FooConfig gets more fields that get populated by NewFooConfig.

Other than that I think I’ve incorporated the main points of both @freeformz and @iignat:

  1. NewBar should not construct Foo and rather take it as input.
  2. Neither NewFoo nor NewBar should force the user to supply optional parameters that have sensible defaults, but should have the option to do so.

Thanks!