So I have an interface, called UserService
inside a package service
I have two simple structs representing the body and response of a HTTP call. I have another struct implementing the UserService
interface.
I want to put these structs, call them UserResponse
and UserRequest
inside the interface so other services can use them to make the HTTP call. Furthermore, the request and response should be available (struct UserReponse
, not struct userResponse
) so other parts of the code can use them.
I define a function in the interface called GetUser(request UserRequest) UserResponse
However, whenever I reference UserRequest
I have to use service.UserRequest
and not service.UserService.UserRequest
. This is bad because I don't want user-related objects to go into the service namespace. I want each service related data to organized under its own interface, file, etc. Unfortunately, I get an error if I put UserResponse
inside the UserService
interface. So I put it at the same level as UserService
, which is why they are showing up as service.UserResponse
. How do I go about accessing UserResponse
as service.UserService.UserResponse
?