easyjson
easyjson copied to clipboard
go 1.18 generics support
I use v0.7.7, code with generics fails:
Error parsing model.go: model.go:41:27: expected ';', found '[' (and 2 more errors)
model.go:1: running "easyjson": exit status 1
Any plans to have generics support in the near future?
+1 Do you have any plans for it?
+1 At the very least generic types should be skipped for processing (potentially with a warning) instead of erroring.
Are there any updates ? There are some problems with types when try to generate code that contains generics with pointer types.
Example:
package some_package;
//easyjson:json
type SecondNested struct {
SomeField bool `json:"someField"`
}
type NestedStruct[U json.Unmarshaler] struct {
SecondNested U `json:"secondNested"`
}
type Main[U json.Unmarshaler] struct {
NestedStructs NestedStruct[U] `json:"nested"`
}
//easyjson:json
type SomeType struct {
Main[*SecondNested]
}
Generated code:
func easyjson<...>SecondNested(in *jlexer.Lexer, out *NestedStruct[*some_package.SecondNested]) {}
func easyjson<...>SecondNested(out *jwriter.Writer, in NestedStruct[*some_package.SecondNested]) {}
Problem is at this type *some_package.SecondNested, there must not be some_package in type declaration.