Interfaces are one of the best tools a software engineer can use. Once you expose something as an interface, you can freely change the implementation behind it. Interfaces are a construct that's being used within a single process. They are extremely useful for testing interactions with other components, which are plentiful in microservice-based systems. Here is one of the interfaces of our sample application:
type UserManager interface {
Register(user User) error
Login(username string, authToken string) (session string, err error)
Logout(username string, session string) error
}
The UserManager interface defines a few methods, their inputs, and outputs. However, it doesn't specify the semantics. For example, what happens if the Login() method is called for an already logged-in user? Is it an error? Is the previous session terminated...