golang/protobuf

Compile google/protobuf/*.proto files into golang structs and add to a new package

bufdev opened this issue · 13 comments

I would be happy to do the work and commit it over, but before doing any work on this, wanted to see how open the maintainers were to it. Thoughts?

Also addresses #49

@peter-edge Hi. Sorry for this, but I just started doing:

sed -i 's/import google_protobuf "google\/protobuf"/import google_protobuf "github.com\/peter-edge\/go-google-protobuf"/' ${proto_dir}/checker.pb.go

Because works. Let me know if I can do anything to help maintain. I'm not sure of how it might be integrated into this project, exactly. But yeah... I have this problem, too.

Why are you so awesome? Thanks. ❤️

This would be awesome. It would make using protobuf with Go significantly easier

build type.proto failed:

protoc version:

protoc --version
libprotoc 3.0.0

error message:

protoc --go_out=. any.proto source_context.proto type.proto
google/protobuf/any.proto:94:10: "google.protobuf.Any.type_url" is already defined in file "any.proto".
google/protobuf/any.proto:97:9: "google.protobuf.Any.value" is already defined in file "any.proto".
google/protobuf/any.proto:73:9: "google.protobuf.Any" is already defined in file "any.proto".
google/protobuf/source_context.proto:46:10: "google.protobuf.SourceContext.file_name" is already defined in file "source_context.proto".
google/protobuf/source_context.proto:43:9: "google.protobuf.SourceContext" is already defined in file "source_context.proto".
type.proto: Import "google/protobuf/any.proto" was not found or had errors.
type.proto: Import "google/protobuf/source_context.proto" was not found or had errors.
type.proto:55:3: "google.protobuf.SourceContext" seems to be defined in "source_context.proto", which is not imported by "type.proto".  To use it here, please add the necessary import.
type.proto:147:3: "google.protobuf.SourceContext" seems to be defined in "source_context.proto", which is not imported by "type.proto".  To use it here, please add the necessary import.
type.proto:167:3: "google.protobuf.Any" seems to be defined in "any.proto", which is not imported by "type.proto".  To use it here, please add the necessary import.

😽

LK4D4 commented

It would be really nice to have those packages compiled

8ea33d2 adds some initial types. I'll add more shortly.

There's zero diff from the google/protobuf .proto files (except for adding a go_package option to make protoc-gen-go generate a good package name, which I hope to upstream).

I put them in separate Go packages since that seemed to make more sense to me, and couldn't think of compelling reasons for them to all be in the same package (their existing package declarations notwithstanding). But I'm happy to hear arguments for them all going together.

Any arguments, @peter-edge?

Okay, I'll leave it as I have it now. Neither approach is perfect, and we can consider changing it in the future, but the current state should be fine.

azr commented

About date/durations,

how about creating some func to get/set timestamps from golang time ?

Like func NewTimestamp(time.Time) *Timestamp and func (t *Timestamp) Time() time.Time & same for Durations ?

Directly in the timestamp pkg, I think it's fine if it's not generated.

I think you are looking for...
https://godoc.org/github.com/golang/protobuf/ptypes#Timestamp
https://godoc.org/github.com/golang/protobuf/ptypes#TimestampProto

Btw, I don't think your comment is related to the original issue.

azr commented

Ah, thx @cybrcodr.
I put it here bcs #49 redirects here, not that much related, yes, sry ! Cheers !