Open gebv opened 4 years ago
@gebv @b5 FYI Starlark recently merged the Unpacker
interface: https://github.com/google/starlark-go/pull/272
I need to solve the Custom Type problem in my application soon, so planning to look into both UnpackArgs
for things other than Starlark function arguments and/or continue using util.Unmarshal
. Will report back if I learn anything that can be contributed here.
Strange that google/starlark-go
has no generic interface for Marshal
. Packer
would make a lot of sense 😄. Any others addressed this problem?
It is proposal and dirty code to illustrate the concept
NOTE: factory object saved in to starlarakstruct.Struct in constructor for unmarshal (no need to global store custom types). Similar to
database.Valuer
Implement custom type via starlarkstruct.Struct Added two interfaces
Added new cases for
util.Marahsl
andutil.Unmarshal
Example custom type
Tests