Closed admannon closed 1 year ago
Describe the bug Generated file dosn't contain generic type.
To Reproduce
go generate
package mapper
//go:generate goverter -ignoreUnexportedFields -packageName mapper -output mapper2.gen.go ./
// goverter:converter // goverter:extend github.com/gotidy/ptr:To.+ type Mapper interface { // goverter:autoMap Content MapTypedToAnother(Typed[InnerType]) ResultType[AnotherInnerType] }
type Typed[S any] struct { ID string Content *S }
type InnerType struct { Name string }
type AnotherInnerType struct { Name string }
type ResultType[S any] struct { ID string Name string Content *S }
- Currently (v0.17.0) this is actual behavior: ```golang // Code generated by github.com/jmattheis/goverter, DO NOT EDIT. package mapper import ( ptr "github.com/gotidy/ptr" ) type MapperImpl struct{} func (c *MapperImpl) MapTypedToAnother(source Typed) ResultType { var mapperResultType ResultType mapperResultType.ID = source.ID var pString *string if source.Content != nil { pString = &source.Content.Name } mapperResultType.Name = ptr.ToString(pString) mapperResultType.Content = c.pMapperInnerTypeToPMapperAnotherInnerType(source.Content) return mapperResultType } func (c *MapperImpl) pMapperInnerTypeToPMapperAnotherInnerType(source *InnerType) *AnotherInnerType { var pMapperAnotherInnerType *AnotherInnerType if source != nil { var mapperAnotherInnerType AnotherInnerType mapperAnotherInnerType.Name = (*source).Name pMapperAnotherInnerType = &mapperAnotherInnerType } return pMapperAnotherInnerType }
Expected behavior
Typed
Typed[InnerType]
ResultType
ResultType[AnotherInnerType]
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT.
import ( ptr "github.com/gotidy/ptr" )
type MapperImpl struct{}
func (c MapperImpl) MapTypedToAnother(source Typed[InnerType]) ResultType[AnotherInnerType] { var mapperResultType ResultType[AnotherInnerType] mapperResultType.ID = source.ID var pString string if source.Content != nil { pString = &source.Content.Name } mapperResultType.Name = ptr.ToString(pString) mapperResultType.Content = c.pMapperInnerTypeToPMapperAnotherInnerType(source.Content) return mapperResultType } func (c MapperImpl) pMapperInnerTypeToPMapperAnotherInnerType(source InnerType) AnotherInnerType { var pMapperAnotherInnerType AnotherInnerType if source != nil { var mapperAnotherInnerType AnotherInnerType mapperAnotherInnerType.Name = (*source).Name pMapperAnotherInnerType = &mapperAnotherInnerType } return pMapperAnotherInnerType }
Hey, thanks for your detailed bug report, I've released a fix with v0.17.1. Could you verify that it works for you?
I have tried it and it works fine. Thank you for the response.
Describe the bug Generated file dosn't contain generic type.
To Reproduce
go generate
with this snippet://go:generate goverter -ignoreUnexportedFields -packageName mapper -output mapper2.gen.go ./
// goverter:converter // goverter:extend github.com/gotidy/ptr:To.+ type Mapper interface { // goverter:autoMap Content MapTypedToAnother(Typed[InnerType]) ResultType[AnotherInnerType] }
type Typed[S any] struct { ID string Content *S }
type InnerType struct { Name string }
type AnotherInnerType struct { Name string }
type ResultType[S any] struct { ID string Name string Content *S }
Expected behavior
Typed
should beTyped[InnerType]
andResultType
should beResultType[AnotherInnerType]
package mapper
import ( ptr "github.com/gotidy/ptr" )
type MapperImpl struct{}
func (c MapperImpl) MapTypedToAnother(source Typed[InnerType]) ResultType[AnotherInnerType] { var mapperResultType ResultType[AnotherInnerType] mapperResultType.ID = source.ID var pString string if source.Content != nil { pString = &source.Content.Name } mapperResultType.Name = ptr.ToString(pString) mapperResultType.Content = c.pMapperInnerTypeToPMapperAnotherInnerType(source.Content) return mapperResultType } func (c MapperImpl) pMapperInnerTypeToPMapperAnotherInnerType(source InnerType) AnotherInnerType { var pMapperAnotherInnerType AnotherInnerType if source != nil { var mapperAnotherInnerType AnotherInnerType mapperAnotherInnerType.Name = (*source).Name pMapperAnotherInnerType = &mapperAnotherInnerType } return pMapperAnotherInnerType }