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
Support "bytes" proto (v2/v3) type. #13
Support "bytes" proto (v2/v3) type. #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good! I was surprised to see the Starlark strings are equivalent to Python's bytes
instead of str
: https://github.com/bazelbuild/starlark/blob/master/spec.md#strings
Can you also add the new test field to test_proto_gogo.proto
? I don't expect gogo does anything different from go-protobuf here, but it's good to keep them similar because it makes the true differences stand out more.
internal/go/skycfg/proto_message.go
Outdated
var err error | ||
// If dst is []byte ([]Uint8) and src is string, attempt to | ||
// convert value below. | ||
if t.Kind() == reflect.Slice && t.Elem().Kind() == reflect.Uint8 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic feels like it belongs in scalarFromStarlark()
. Since the Go type is passed in already, you can special-case the conversion from string
to []uint8
and return a reflected slice (which should be assignable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Also done. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm going to force the merge past test errors because it got stuck on a bad base commit. |
Thanks! |
I ran into this when trying to set
.data
oncorev1.Secret
message (it is of typemap<string, bytes>
). Since Starlark lacksbytes
type like Python I think it's best to just implicitly convert this tostring
type.