-
Notifications
You must be signed in to change notification settings - Fork 810
Rename vanity.NotInPackageGoogleProtobuf to vanity.NotGoogleProtobufDescriptorProto, only restrict file google/protobuf/descriptor.proto #141
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
Rename vanity.NotInPackageGoogleProtobuf to vanity.NotGoogleProtobufDescriptorProto, only restrict file google/protobuf/descriptor.proto #141
Conversation
…escriptorProto, only restrict file google/protobuf/descriptor.proto Signed-off-by: Peter Edge <[email protected]>
If you want to see what the FileDescriptorProto looks like: package main
import (
"bytes"
"compress/gzip"
"fmt"
"io/ioutil"
"os"
"go.pedge.io/lion/proto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
)
func main() {
if err := do(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
os.Exit(1)
}
os.Exit(0)
}
func do() error {
// golang/protobuf has gzipped file descriptors built in
// https://github.com/golang/protobuf/blob/6aaa8d47701fa6cf07e914ec01fde3d4a1fe79c3/protoc-gen-go/descriptor/descriptor.pb.go#L1707
fileDescriptor, _ := (&descriptor.FileDescriptorSet{}).Descriptor()
gzipReader, err := gzip.NewReader(bytes.NewReader(fileDescriptor))
if err != nil {
return err
}
data, err := ioutil.ReadAll(gzipReader)
if err != nil {
return err
}
message := &descriptor.FileDescriptorProto{}
if err := proto.Unmarshal(data, message); err != nil {
return err
}
// my logging library that has specific printing of protocol buffer messages
protolion.Print(message)
return nil
} |
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.
Can you remove this comment I don't think its necessary.
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.
See HasSuffix comment, that's why I added it :) haha
Are you ok with giving your copyright over to us for this pull request? |
Ya of course |
The copyright specifically for this PR, that is |
yes |
Signed-off-by: Peter Edge <[email protected]>
I think we can do better. |
This is an improvement over the existing code, is there no reason not to On Monday, February 1, 2016, Walter Schulze [email protected]
|
If you have an idea for something better, please tell me, otherwise I'm not On Monday, February 1, 2016, Peter Edge [email protected] wrote:
|
What about a filepath.Split ? |
How is that different? Outlawing cases like "protodescriptor.proto"? |
…criptor.proto file in NotGoogleProtobufDescriptorProto Signed-off-by: Peter Edge <[email protected]>
Much better :) |
I'm sure it is, but I can test it to double check. On Tue, Feb 2, 2016 at 4:38 PM, Walter Schulze [email protected]
|
Never be sure. Always test. |
I have confirmed that this fixes the issue with a manual compile |
@awalterschulze just checking in, that means that yes, i tested it and i confirmed it works :) |
Yes sorry my bad. I have not forgotten about this pull request, but I have been quite busy and I also wanted to test this myself. I first want to see what golang/protobuf does with its new proto3 google/protobuf types. This also links to proto3 #57 not being fully supported yet in gogoprotobuf. I don't want to make a change now that I will possibly have to revert. |
Protobuf/50 is irrelevant to this PR man. Anything that happens there has On Tuesday, February 9, 2016, Walter Schulze [email protected]
|
Do the types in Protobuf/50 not also have a package name "google.protobuf" ? |
Yep, but this isn't affected by this PR - the compiler will see no On Tuesday, February 9, 2016, Walter Schulze [email protected]
|
I am happy to talk like this. |
But that does not have to do with this PR - even if it does, then this On Tue, Feb 9, 2016 at 12:18 PM, Walter Schulze [email protected]
|
I don't know what to say anymore, but please be patient. |
We can, it's certainly your decision, but we're having a fundamental On Tue, Feb 9, 2016 at 12:24 PM, Walter Schulze [email protected]
|
I think they are connected, maybe you can show me how given a new proto3 type you do not change the generated code with this change. |
The only change here is that anything in google.protobuf that is not in descriptor.proto will be allowed to have special gogoprotobuf code generated for it. This means, for example, that google.protobuf.Timestamp will have the additional Marshal/Unmarshal related methods (like Size) attached to it. No other code, or generated code, is affected. This actually fixes a bug, where if you use gofast/gogofast/gogofaster/gogoslick, that if you have a message such as this:
And you use gogofast etc, that correct code will actually be produced. Otherwise you will get a bug saying that no method for Size can be found on Timestamp. The only generated code that changes is if you generate code for google.protobuf.* that is not in descriptor, which should change regardless of issue 50 (in fact, for issue 50 to work when you merge in the changes from golang/protobuf, you will need this PR to produce valid code with gogofast etc). |
I can guess how golang/protobuf is going to handle these new proto3 types, but I can not know for sure. |
@awalterschulze |
I am busy merging in ptypes, when that is done I'll revisit this issue. |
Great, would greatly appreciate it :) |
Signed-off-by: Peter Edge [email protected]
#137