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

Support for merging messages implementing Merger which are embedded by value #710

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a-palchikov
Copy link

This PR fixes a small issue with Clone to enable support for proto.Merger for types that are embedded as values.
Example of such scenario is overriding the type of the generated protobuf attribite to use a type from the Go's standard library - e.g. time.Time:

message MyResource {
    // ...
    // Created defines the creation timestamp.
    google.protobuf.Timestamp Created = 1 [
        (gogoproto.stdtime) = true,
        (gogoproto.nullable) = false,
        (gogoproto.jsontag) = "created"
    ];
    // ...
}

which results in the following type:

type MyResource struct {
	// ...
	// Created defines the creation timestamp.
	Created *time.Time `protobuf:"bytes,1,opt,name=Created,stdtime" json:"created,omitempty"`

Values of such type cannot be Cloned as time.Time has unexported fields.
Additionally, if MyResource implements proto.Merger it is not used.

I'm not entirely sure this is the correct repository for this change as iiuc the proto/ code is partially based on another repository which, in turn, is using yet another one. I'd appreciate it if you let me know whether this change is better addressed in one of these repositories instead.

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.

None yet

1 participant