Manato Kuroda
Jun 26, 2022

--

Hi, thanks for your question.

The role of registy is to provide specific implementations to conform to the interface.

https://github.com/manakuro/golang-clean-architecture/blob/56e27ebb48ab33a037a77aa5245372cf9616ec10/registry/user_registry.go#L12-L26

The appController interface is used in router.go and each routes require the interface such as `User.GetUsers`.

https://github.com/manakuro/golang-clean-architecture/blob/b4eec8dc475a01da4d971bcba02275f815ceb32f/infrastructure/router/router.go#L14

In order to conform to the interface, the registry needs to generate userController type and pass it to the route. It does not ruin the purpose of abstraction because the user_registry requires the controller interface here.

https://github.com/manakuro/golang-clean-architecture/blob/56e27ebb48ab33a037a77aa5245372cf9616ec10/registry/user_registry.go#L12

And since a specific implementation can be replaced there, the abstraction is preserved.

--

--

Responses (1)