Describe the bug
When instructed to use map . Target with pointer Source, goverter generates a helper converter, stripping away the pointer. This causes go vet to spam warnings when used with Protobuf generated structures, each of which contain a lock inside, resulting in it being copied.
It becomes noticeable with definitions like these:
// goverter:converter
// goverter:output:file ./gen.go
type Converter interface {
// goverter:map A A2
Source2TargetBase(s *Source) *TargetBase
// goverter:map . Base
Source2Target(s *Source) *Target
}
To Reproduce
Full minimal example to reproduce:
type Source struct {
A int
B int
}
type TargetBase struct {
A int
}
type Target struct {
Base TargetBase
B int
}
// goverter:converter
// goverter:output:file ./gen.go
type Converter interface {
Source2TargetBase(s *Source) *TargetBase
// goverter:map . Base
Source2Target(s *Source) *Target
}
Generates the following code, which, as can be seen, even ignores the already defined Source2Target in favor of a generated helper with stripped pointer on the source:
type ConverterImpl struct{}
func (c *ConverterImpl) Source2Target(source *Source) *Target {
var pInternalTarget *Target
if source != nil {
var internalTarget Target
internalTarget.Base = c.internalSourceToInternalTargetBase((*source))
internalTarget.B = (*source).B
pInternalTarget = &internalTarget
}
return pInternalTarget
}
func (c *ConverterImpl) Source2TargetBase(source *Source) *TargetBase {
var pInternalTargetBase *TargetBase
if source != nil {
internalTargetBase := c.internalSourceToInternalTargetBase((*source))
pInternalTargetBase = &internalTargetBase
}
return pInternalTargetBase
}
func (c *ConverterImpl) internalSourceToInternalTargetBase(source Source) TargetBase {
var internalTargetBase TargetBase
internalTargetBase.A = source.A
return internalTargetBase
}
Expected behavior
Preserve the exact same source type when auto-generating helpers while using map .. OR at least prefer an already defined method with pointer receiver instead of generating a new one.
Describe the bug
When instructed to use
map . Targetwith pointerSource, goverter generates a helper converter, stripping away the pointer. This causesgo vetto spam warnings when used with Protobuf generated structures, each of which contain a lock inside, resulting in it being copied.It becomes noticeable with definitions like these:
To Reproduce
Full minimal example to reproduce:
Generates the following code, which, as can be seen, even ignores the already defined
Source2Targetin favor of a generated helper with stripped pointer on the source:Expected behavior
Preserve the exact same source type when auto-generating helpers while using
map .. OR at least prefer an already defined method with pointer receiver instead of generating a new one.