Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support custom type and fixed bugs #49

Merged
merged 10 commits into from
Jun 19, 2020
Merged

Added support custom type and fixed bugs #49

merged 10 commits into from
Jun 19, 2020

Conversation

gebv
Copy link
Contributor

@gebv gebv commented Apr 8, 2020

gebv added 6 commits April 8, 2020 14:59
- added Unmarshaler\Marshaler interfaces
- (fix) unmarshal NoneType to nil
- (refactoring) added supported for dict if key is not string - transform to map[interface{}]interface{}
- added packages for tests
- added github.com/pkg/errors
Copy link
Member

@b5 b5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So sorry for the delay on this @gebv, and thanks so much for your contributions. I have some small change requests, and would love to get this merged.

Thanks again!

util/util.go Outdated Show resolved Hide resolved
util/util.go Outdated Show resolved Hide resolved
Comment on lines +136 to +146
case *starlarkstruct.Struct:
if _var, ok := v.Constructor().(Unmarshaler); ok {
err = _var.UnmarshalStarlark(x)
if err != nil {
err = errors.Wrapf(err, "failed marshal %q to Starlark object", v.Constructor().Type())
return
}
val = _var
} else {
err = fmt.Errorf("constructor object from *starlarkstruct.Struct not supported Marshaler to starlark object: %s", v.Constructor().Type())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition!

util/util.go Outdated
Comment on lines 236 to 238
type Unmarshaler interface {
UnmarshalStarlark(starlark.Value) error
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause golint to fail. Both the Unmarshaler interface and UnmarshalStarlark methods should have comments that explain their use.

util/util.go Outdated
Comment on lines 240 to 242
type Marshaler interface {
MarshalStarlark() (starlark.Value, error)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Unmarshaler, this will cause golint to fail. Both the Marshaler interface and MarshalStarlark methods should have comments that explain their use.

gebv and others added 4 commits May 14, 2020 20:02
Co-authored-by: Brendan O'Brien <sparkle_pony_2000@qri.io>
Co-authored-by: Brendan O'Brien <sparkle_pony_2000@qri.io>
@gebv gebv requested a review from b5 May 14, 2020 14:10
@gebv
Copy link
Contributor Author

gebv commented Jun 19, 2020

Any updates?

Copy link
Member

@b5 b5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks!

@b5 b5 merged commit c32c667 into qri-io:master Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants