kratos-shop icon indicating copy to clipboard operation
kratos-shop copied to clipboard

模块之间有重复代码

Open EchoGroot opened this issue 2 years ago • 2 comments

https://github.com/aliliin/kratos-shop/blob/main/service/user/internal/data/user.go https://github.com/aliliin/kratos-shop/blob/main/shop/internal/data/user.go

我写go项目也遇到这个问题了,多模块的项目,存在大量重复代码。请问这方面有什么改进的建议吗?

EchoGroot avatar Jun 07 '22 02:06 EchoGroot

分开有分开的好处,合起来有合起来的好处,合起来代码可以复用,改bug不容易漏改,但是也是因为这个问题,如果你改了代码有bug,会导致所有服务都会有这个bug,一般拆分微服务,都是不同人维护不同的服务的,所以我感觉重复就重复吧。

godsoul avatar Jan 17 '23 03:01 godsoul

一点复制粘贴优于彼此依赖,这也是一些Go的设计哲学

mizumoto-cn avatar Feb 03 '23 05:02 mizumoto-cn