Re: [go-nuts] Code duplication in similar structs

2020-11-09 Thread Robert Engels
If the logic is the same, wrap the field in an accessor method and use an interface. > On Nov 9, 2020, at 9:11 PM, Brandon Busby > wrote: > > I have structs with duplicate fields and duplicate code to go along with > them. The problem is that the duplicate code does make use of non-common

Re: [go-nuts] Code duplication in similar structs

2020-11-09 Thread Brandon Busby
I have structs with duplicate fields and duplicate code to go along with them. The problem is that the duplicate code does make use of non-common fields. Here is an example of the code. https://play.golang.org/p/IkoNJTdoVLD I could extract the duplicate code sections into a method, eliminatin