Closed JessedeJonge closed 1 year ago
Goverter cannot know how to convert inteface{} to interface{} and thus fails. You must define the conversion method yourself. E.g.
package example
// goverter:converter
// goverter:extend ConvertInterface
type Converter interface {
Convert(source Input) Output
}
type Input struct {
Age interface{}
}
type Output struct {
Age interface{}
}
func ConvertInterface(value interface{}) interface{} {
// convert value
converted := value
return converted
}
Thank you, unfortabetely I am still getting panics after implementing the ConvertInteterface method.
panic: unsupported type interface{}
goroutine 1 [running]:
github.com/jmattheis/goverter/xtype.toCode({0x1047c4fa0?, 0x104919b20?})
/Users/jessedejonge/go/pkg/mod/github.com/jmattheis/goverter@v0.17.2/xtype/type.go:268 +0xc3c
github.com/jmattheis/goverter/xtype.toCode({0x1047c4fc8?, 0x140001e5600})
/Users/jessedejonge/go/pkg/mod/github.com/jmattheis/goverter@v0.17.2/xtype/type.go:256 +0x2d4
github.com/jmattheis/goverter/xtype.Type.TypeAsJen({{0x1047c4fc8, 0x140001e5600}, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
/Users/jessedejonge/go/pkg/mod/github.com/jmattheis/goverter@v0.17.2/xtype/type.go:248 +0x48
github.com/jmattheis/goverter/builder.(*Map).Build(0x1047834c0, {0x1047c4640, 0x140005f26e0}, 0x14000332540, 0x14000416600, 0x140004970e0, 0x14000496aa0)
Could you try out v0.17.3
? It should be fixed there.
That worked. Thank you for the fix!
Have you read the project readme?
Describe your question I have three layers: database, service and api
For the convertor from database -> service I am using the following custom function for json.RawMessages (empty by default JSONB columns):
This fixes a panic
panic: unsupported type interface{}
After that, I try to convert service layer to api layer but get error:
Any help ?