I am working in a microservice architecture ( my first one ), in Golang, and I find myself duplicating Models definition over several services.
What can I do to avoid this?
I can only think to implementing a shared library with all my model definitions but I can't evaluate pros and cons. Can you tell me about other ways to solve this issue?
The idea you already mentioned can't be that wrong. When you have a set of services sharing the same models, it can be a good idea to extract these models into an own package/module.
We decided to do this in a Java-Project a few months ago and it made things a lot easier. Especially when your services are decoupled used some type of messaging/streaming, you absolutely have a set of common entities they need for communication.