Merge pull request #54786 from shiywang/bump-protobuf

Automatic merge from submit-queue (batch tested with PRs 55093, 54966, 55047, 54971, 54786). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

vendor update: github.com/golang/protobuf

When I'm working on PR: https://github.com/kubernetes/kubernetes/pull/54782, I met a problem here: https://github.com/golang/protobuf/issues/372, which I think we need to update our vendor of protobuf
and I ask Dr. Stefan for suggestion, here is our coversation

shiywang [5:09 PM]
hi, Dr. Stefan i'm sorry to bother, I have a simple question, I was working on a pr which need to use protobuf custom field, and I run into this problem here: https://github.com/golang/protobuf/issues/372  which I think is due to our codebase's protobuf vendor is too old `vendor/github.com/golang/protobuf`,  do you think I can update that vendor to lastest one ?  also I noticed there's also an extend package called `vendor/github.com/gogo/protobuf/proto` what's the releationship between those two ?  which one should I update ?

sttts
[5:11 PM]
hi

[5:11]
don't know much about the proto internals either, @claytonc is probably the only one

[5:12]
create a vendor/github.com/golang/protobuf bump PR and assign it to him

shiywang [5:12 PM]
sounds good, thank you sir

so
/assign @smarterclayton
for suggestion, thanks

```release-note
NONE
```

Kubernetes-commit: 5b7ce60fcebea445b7852d8dc2bce141a2bd7a3a
This commit is contained in:
Kubernetes Publisher 2017-11-06 20:39:05 -08:00
commit 62461cc6ff
14 changed files with 301 additions and 169 deletions

118
Godeps/Godeps.json generated
View File

@ -132,23 +132,23 @@
}, },
{ {
"ImportPath": "github.com/golang/protobuf/proto", "ImportPath": "github.com/golang/protobuf/proto",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" "Rev": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
}, },
{ {
"ImportPath": "github.com/golang/protobuf/ptypes", "ImportPath": "github.com/golang/protobuf/ptypes",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" "Rev": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
}, },
{ {
"ImportPath": "github.com/golang/protobuf/ptypes/any", "ImportPath": "github.com/golang/protobuf/ptypes/any",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" "Rev": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
}, },
{ {
"ImportPath": "github.com/golang/protobuf/ptypes/duration", "ImportPath": "github.com/golang/protobuf/ptypes/duration",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" "Rev": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
}, },
{ {
"ImportPath": "github.com/golang/protobuf/ptypes/timestamp", "ImportPath": "github.com/golang/protobuf/ptypes/timestamp",
"Rev": "4bd1920723d7b7c925de087aa32e2187708897f7" "Rev": "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
}, },
{ {
"ImportPath": "github.com/google/btree", "ImportPath": "github.com/google/btree",
@ -476,219 +476,219 @@
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing", "ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/conversion/unstructured",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "412b7b58e0bf04b176d52dd067b5d57a7d097972" "Rev": "95740bed589a312230fa657b096af634ba6ef5e5"
}, },
{ {
"ImportPath": "k8s.io/kube-openapi/pkg/common", "ImportPath": "k8s.io/kube-openapi/pkg/common",

View File

@ -174,11 +174,11 @@ func sizeFixed32(x uint64) int {
// This is the format used for the sint64 protocol buffer type. // This is the format used for the sint64 protocol buffer type.
func (p *Buffer) EncodeZigzag64(x uint64) error { func (p *Buffer) EncodeZigzag64(x uint64) error {
// use signed number to get arithmetic right shift. // use signed number to get arithmetic right shift.
return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
func sizeZigzag64(x uint64) int { func sizeZigzag64(x uint64) int {
return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) return sizeVarint((x << 1) ^ uint64((int64(x) >> 63)))
} }
// EncodeZigzag32 writes a zigzag-encoded 32-bit integer // EncodeZigzag32 writes a zigzag-encoded 32-bit integer
@ -1075,10 +1075,17 @@ func (o *Buffer) enc_map(p *Properties, base structPointer) error {
func (o *Buffer) enc_exts(p *Properties, base structPointer) error { func (o *Buffer) enc_exts(p *Properties, base structPointer) error {
exts := structPointer_Extensions(base, p.field) exts := structPointer_Extensions(base, p.field)
if err := encodeExtensions(exts); err != nil {
v, mu := exts.extensionsRead()
if v == nil {
return nil
}
mu.Lock()
defer mu.Unlock()
if err := encodeExtensionsMap(v); err != nil {
return err return err
} }
v, _ := exts.extensionsRead()
return o.enc_map_body(v) return o.enc_map_body(v)
} }

View File

@ -154,6 +154,7 @@ type ExtensionDesc struct {
Field int32 // field number Field int32 // field number
Name string // fully-qualified name of extension, for text formatting Name string // fully-qualified name of extension, for text formatting
Tag string // protobuf tag style Tag string // protobuf tag style
Filename string // name of the file in which the extension is defined
} }
func (ed *ExtensionDesc) repeated() bool { func (ed *ExtensionDesc) repeated() bool {

View File

@ -73,7 +73,6 @@ for a protocol buffer variable v:
When the .proto file specifies `syntax="proto3"`, there are some differences: When the .proto file specifies `syntax="proto3"`, there are some differences:
- Non-repeated fields of non-message type are values instead of pointers. - Non-repeated fields of non-message type are values instead of pointers.
- Getters are only generated for message and oneof fields.
- Enum types do not get an Enum method. - Enum types do not get an Enum method.
The simplest way to describe this is to see an example. The simplest way to describe this is to see an example.

View File

@ -865,7 +865,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
return p.readStruct(fv, terminator) return p.readStruct(fv, terminator)
case reflect.Uint32: case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
fv.SetUint(uint64(x)) fv.SetUint(x)
return nil return nil
} }
case reflect.Uint64: case reflect.Uint64:

View File

@ -51,6 +51,9 @@ const googleApis = "type.googleapis.com/"
// function. AnyMessageName is provided for less common use cases like filtering a // function. AnyMessageName is provided for less common use cases like filtering a
// sequence of Any messages based on a set of allowed message type names. // sequence of Any messages based on a set of allowed message type names.
func AnyMessageName(any *any.Any) (string, error) { func AnyMessageName(any *any.Any) (string, error) {
if any == nil {
return "", fmt.Errorf("message is nil")
}
slash := strings.LastIndex(any.TypeUrl, "/") slash := strings.LastIndex(any.TypeUrl, "/")
if slash < 0 { if slash < 0 {
return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl) return "", fmt.Errorf("message type url %q is invalid", any.TypeUrl)

View File

@ -1,12 +1,11 @@
// Code generated by protoc-gen-go. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/golang/protobuf/ptypes/any/any.proto // source: google/protobuf/any.proto
// DO NOT EDIT!
/* /*
Package any is a generated protocol buffer package. Package any is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
github.com/golang/protobuf/ptypes/any/any.proto google/protobuf/any.proto
It has these top-level messages: It has these top-level messages:
Any Any
@ -63,6 +62,16 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// any.Unpack(foo) // any.Unpack(foo)
// ... // ...
// //
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use // The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack // 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/' // methods only use the fully qualified type name after the last '/'
@ -132,24 +141,38 @@ func (*Any) ProtoMessage() {}
func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Any) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (*Any) XXX_WellKnownType() string { return "Any" } func (*Any) XXX_WellKnownType() string { return "Any" }
func (m *Any) GetTypeUrl() string {
if m != nil {
return m.TypeUrl
}
return ""
}
func (m *Any) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
func init() { func init() {
proto.RegisterType((*Any)(nil), "google.protobuf.Any") proto.RegisterType((*Any)(nil), "google.protobuf.Any")
} }
func init() { proto.RegisterFile("github.com/golang/protobuf/ptypes/any/any.proto", fileDescriptor0) } func init() { proto.RegisterFile("google/protobuf/any.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 187 bytes of a gzipped FileDescriptorProto // 185 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xd2, 0x4f, 0xcf, 0x2c, 0xc9, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4c, 0xcf, 0xcf, 0x4f,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0xcc, 0xab, 0xd4,
0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0xcc, 0x03, 0x73, 0x84, 0xf8, 0x21, 0x52, 0x7a, 0x30, 0x29, 0x25, 0x33, 0x2e, 0x66, 0xc7, 0xbc, 0x4a,
0xab, 0x04, 0x61, 0x3d, 0xb0, 0xb8, 0x10, 0x7f, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x1e, 0x4c, 0x21, 0x49, 0x2e, 0x8e, 0x92, 0xca, 0x82, 0xd4, 0xf8, 0xd2, 0xa2, 0x1c, 0x09, 0x46, 0x05, 0x46,
0x95, 0x92, 0x19, 0x17, 0xb3, 0x63, 0x5e, 0xa5, 0x90, 0x24, 0x17, 0x07, 0x48, 0x79, 0x7c, 0x69, 0x0d, 0xce, 0x20, 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37, 0x06, 0x04, 0x00, 0xcb, 0x2f, 0xcf, 0x0b, 0x01, 0x29, 0x4d, 0x62, 0x03, 0xeb, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff,
0x00, 0xff, 0xff, 0xc6, 0x4d, 0x03, 0x23, 0xf6, 0x00, 0x00, 0x00, 0xff, 0x13, 0xf8, 0xe8, 0x42, 0xdd, 0x00, 0x00, 0x00,
} }

View File

@ -37,7 +37,6 @@ option go_package = "github.com/golang/protobuf/ptypes/any";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto"; option java_outer_classname = "AnyProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// `Any` contains an arbitrary serialized protocol buffer message along with a // `Any` contains an arbitrary serialized protocol buffer message along with a
@ -75,6 +74,16 @@ option objc_class_prefix = "GPB";
// any.Unpack(foo) // any.Unpack(foo)
// ... // ...
// //
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
// The pack methods provided by protobuf library will by default use // The pack methods provided by protobuf library will by default use
// 'type.googleapis.com/full.type.name' as the type URL and the unpack // 'type.googleapis.com/full.type.name' as the type URL and the unpack
// methods only use the fully qualified type name after the last '/' // methods only use the fully qualified type name after the last '/'

View File

@ -1,12 +1,11 @@
// Code generated by protoc-gen-go. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/golang/protobuf/ptypes/duration/duration.proto // source: google/protobuf/duration.proto
// DO NOT EDIT!
/* /*
Package duration is a generated protocol buffer package. Package duration is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
github.com/golang/protobuf/ptypes/duration/duration.proto google/protobuf/duration.proto
It has these top-level messages: It has these top-level messages:
Duration Duration
@ -35,6 +34,8 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// two Timestamp values is a Duration and it can be added or subtracted // two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years. // from a Timestamp. Range is approximately +-10,000 years.
// //
// # Examples
//
// Example 1: Compute Duration from two Timestamps in pseudo code. // Example 1: Compute Duration from two Timestamps in pseudo code.
// //
// Timestamp start = ...; // Timestamp start = ...;
@ -69,10 +70,27 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// end.nanos -= 1000000000; // end.nanos -= 1000000000;
// } // }
// //
// Example 3: Compute Duration from datetime.timedelta in Python.
//
// td = datetime.timedelta(days=3, minutes=10)
// duration = Duration()
// duration.FromTimedelta(td)
//
// # JSON Mapping
//
// In JSON format, the Duration type is encoded as a string rather than an
// object, where the string ends in the suffix "s" (indicating seconds) and
// is preceded by the number of seconds, with nanoseconds expressed as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
// //
type Duration struct { type Duration struct {
// Signed seconds of the span of time. Must be from -315,576,000,000 // Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. // to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
// Signed fractions of a second at nanosecond resolution of the span // Signed fractions of a second at nanosecond resolution of the span
// of time. Durations less than one second are represented with a 0 // of time. Durations less than one second are represented with a 0
@ -89,26 +107,38 @@ func (*Duration) ProtoMessage() {}
func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (*Duration) XXX_WellKnownType() string { return "Duration" } func (*Duration) XXX_WellKnownType() string { return "Duration" }
func (m *Duration) GetSeconds() int64 {
if m != nil {
return m.Seconds
}
return 0
}
func (m *Duration) GetNanos() int32 {
if m != nil {
return m.Nanos
}
return 0
}
func init() { func init() {
proto.RegisterType((*Duration)(nil), "google.protobuf.Duration") proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
} }
func init() { func init() { proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor0) }
proto.RegisterFile("github.com/golang/protobuf/ptypes/duration/duration.proto", fileDescriptor0)
}
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 189 bytes of a gzipped FileDescriptorProto // 190 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4c, 0xcf, 0x2c, 0xc9, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f,
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0xcf, 0x49, 0xcc, 0x4b, 0xd7, 0x2f, 0x28, 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a,
0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x2f, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x4f, 0x29, 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56,
0x2d, 0x4a, 0x2c, 0xc9, 0xcc, 0xcf, 0x83, 0x33, 0xf4, 0xc0, 0x2a, 0x84, 0xf8, 0xd3, 0xf3, 0xf3, 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0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 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0x62, 0x6e, 0x00, 0x54, 0xa9, 0x5e, 0x78,
0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x2d, 0x49, 0x6c, 0x60, 0x33, 0x8c, 0x01, 0x6a, 0x4e, 0x8e, 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x4b, 0x12, 0x1b, 0xd8, 0x0c, 0x63,
0x01, 0x00, 0x00, 0xff, 0xff, 0x62, 0xfb, 0xb1, 0x51, 0x0e, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x84, 0x30, 0xff, 0xf3, 0x00, 0x00, 0x00,
} }

View File

@ -33,11 +33,11 @@ syntax = "proto3";
package google.protobuf; package google.protobuf;
option csharp_namespace = "Google.Protobuf.WellKnownTypes"; option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option cc_enable_arenas = true;
option go_package = "github.com/golang/protobuf/ptypes/duration"; option go_package = "github.com/golang/protobuf/ptypes/duration";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "DurationProto"; option java_outer_classname = "DurationProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A Duration represents a signed, fixed-length span of time represented // A Duration represents a signed, fixed-length span of time represented
@ -47,6 +47,8 @@ option objc_class_prefix = "GPB";
// two Timestamp values is a Duration and it can be added or subtracted // two Timestamp values is a Duration and it can be added or subtracted
// from a Timestamp. Range is approximately +-10,000 years. // from a Timestamp. Range is approximately +-10,000 years.
// //
// # Examples
//
// Example 1: Compute Duration from two Timestamps in pseudo code. // Example 1: Compute Duration from two Timestamps in pseudo code.
// //
// Timestamp start = ...; // Timestamp start = ...;
@ -81,11 +83,28 @@ option objc_class_prefix = "GPB";
// end.nanos -= 1000000000; // end.nanos -= 1000000000;
// } // }
// //
// Example 3: Compute Duration from datetime.timedelta in Python.
//
// td = datetime.timedelta(days=3, minutes=10)
// duration = Duration()
// duration.FromTimedelta(td)
//
// # JSON Mapping
//
// In JSON format, the Duration type is encoded as a string rather than an
// object, where the string ends in the suffix "s" (indicating seconds) and
// is preceded by the number of seconds, with nanoseconds expressed as
// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
// microsecond should be expressed in JSON format as "3.000001s".
//
// //
message Duration { message Duration {
// Signed seconds of the span of time. Must be from -315,576,000,000 // Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. // to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
int64 seconds = 1; int64 seconds = 1;
// Signed fractions of a second at nanosecond resolution of the span // Signed fractions of a second at nanosecond resolution of the span

View File

@ -8,14 +8,7 @@
PKG=github.com/golang/protobuf/ptypes PKG=github.com/golang/protobuf/ptypes
UPSTREAM=https://github.com/google/protobuf UPSTREAM=https://github.com/google/protobuf
UPSTREAM_SUBDIR=src/google/protobuf UPSTREAM_SUBDIR=src/google/protobuf
PROTO_FILES=' PROTO_FILES=(any duration empty struct timestamp wrappers)
any.proto
duration.proto
empty.proto
struct.proto
timestamp.proto
wrappers.proto
'
function die() { function die() {
echo 1>&2 $* echo 1>&2 $*
@ -36,31 +29,15 @@ pkgdir=$(go list -f '{{.Dir}}' $PKG)
echo 1>&2 $pkgdir echo 1>&2 $pkgdir
base=$(echo $pkgdir | sed "s,/$PKG\$,,") base=$(echo $pkgdir | sed "s,/$PKG\$,,")
echo 1>&2 "base: $base" echo 1>&2 "base: $base"
cd $base cd "$base"
echo 1>&2 "fetching latest protos... " echo 1>&2 "fetching latest protos... "
git clone -q $UPSTREAM $tmpdir git clone -q $UPSTREAM $tmpdir
# Pass 1: build mapping from upstream filename to our filename.
declare -A filename_map for file in ${PROTO_FILES[@]}; do
for f in $(cd $PKG && find * -name '*.proto'); do echo 1>&2 "* $file"
echo -n 1>&2 "looking for latest version of $f... " protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die
up=$(cd $tmpdir/$UPSTREAM_SUBDIR && find * -name $(basename $f) | grep -v /testdata/) cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file
echo 1>&2 $up
if [ $(echo $up | wc -w) != "1" ]; then
die "not exactly one match"
fi
filename_map[$up]=$f
done
# Pass 2: copy files
for up in "${!filename_map[@]}"; do
f=${filename_map[$up]}
shortname=$(basename $f | sed 's,\.proto$,,')
cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f
done done
# Run protoc once per package.
for dir in $(find $PKG -name '*.proto' | xargs dirname | sort | uniq); do
echo 1>&2 "* $dir"
protoc --go_out=. $dir/*.proto
done
echo 1>&2 "All OK" echo 1>&2 "All OK"

View File

@ -99,6 +99,15 @@ func Timestamp(ts *tspb.Timestamp) (time.Time, error) {
return t, validateTimestamp(ts) return t, validateTimestamp(ts)
} }
// TimestampNow returns a google.protobuf.Timestamp for the current time.
func TimestampNow() *tspb.Timestamp {
ts, err := TimestampProto(time.Now())
if err != nil {
panic("ptypes: time.Now() out of Timestamp range")
}
return ts
}
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto. // TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
// It returns an error if the resulting Timestamp is invalid. // It returns an error if the resulting Timestamp is invalid.
func TimestampProto(t time.Time) (*tspb.Timestamp, error) { func TimestampProto(t time.Time) (*tspb.Timestamp, error) {

View File

@ -1,12 +1,11 @@
// Code generated by protoc-gen-go. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: github.com/golang/protobuf/ptypes/timestamp/timestamp.proto // source: google/protobuf/timestamp.proto
// DO NOT EDIT!
/* /*
Package timestamp is a generated protocol buffer package. Package timestamp is a generated protocol buffer package.
It is generated from these files: It is generated from these files:
github.com/golang/protobuf/ptypes/timestamp/timestamp.proto google/protobuf/timestamp.proto
It has these top-level messages: It has these top-level messages:
Timestamp Timestamp
@ -40,6 +39,8 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// and from RFC 3339 date strings. // and from RFC 3339 date strings.
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
// //
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`. // Example 1: Compute Timestamp from POSIX `time()`.
// //
// Timestamp timestamp; // Timestamp timestamp;
@ -77,15 +78,36 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
// //
// Example 5: Compute Timestamp from current time in Python. // Example 5: Compute Timestamp from current time in Python.
// //
// now = time.time() // timestamp = Timestamp()
// seconds = int(now) // timestamp.GetCurrentTime()
// nanos = int((now - seconds) * 10**9) //
// timestamp = Timestamp(seconds=seconds, nanos=nanos) // # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required, though only UTC (as indicated by "Z") is presently supported.
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
// to obtain a formatter capable of generating timestamps in this format.
// //
// //
type Timestamp struct { type Timestamp struct {
// Represents seconds of UTC time since Unix epoch // Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive. // 9999-12-31T23:59:59Z inclusive.
Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"` Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
// Non-negative fractions of a second at nanosecond resolution. Negative // Non-negative fractions of a second at nanosecond resolution. Negative
@ -101,27 +123,38 @@ func (*Timestamp) ProtoMessage() {}
func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } func (*Timestamp) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" } func (*Timestamp) XXX_WellKnownType() string { return "Timestamp" }
func (m *Timestamp) GetSeconds() int64 {
if m != nil {
return m.Seconds
}
return 0
}
func (m *Timestamp) GetNanos() int32 {
if m != nil {
return m.Nanos
}
return 0
}
func init() { func init() {
proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp") proto.RegisterType((*Timestamp)(nil), "google.protobuf.Timestamp")
} }
func init() { func init() { proto.RegisterFile("google/protobuf/timestamp.proto", fileDescriptor0) }
proto.RegisterFile("github.com/golang/protobuf/ptypes/timestamp/timestamp.proto", fileDescriptor0)
}
var fileDescriptor0 = []byte{ var fileDescriptor0 = []byte{
// 194 bytes of a gzipped FileDescriptorProto // 191 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x4e,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, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x72, 0x7e, 0xae, 0x1e, 0x9a, 0x99, 0x4e, 0x7c, 0x70, 0x13, 0x03, 0x40, 0x42, 0x01, 0x8c, 0x51,
0xd6, 0x20, 0x08, 0xc7, 0xa9, 0x91, 0x91, 0x4b, 0x38, 0x39, 0x3f, 0x57, 0x0f, 0xcd, 0x50, 0x27, 0xda, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0x39, 0x89,
0x3e, 0xb8, 0x91, 0x01, 0x20, 0xa1, 0x00, 0xc6, 0x28, 0x6d, 0x12, 0x1c, 0xbd, 0x80, 0x91, 0xf1, 0x79, 0xe9, 0x08, 0x27, 0x16, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x23, 0x5c, 0xfa, 0x83, 0x91, 0x71,
0x07, 0x23, 0xe3, 0x22, 0x26, 0x66, 0xf7, 0x00, 0xa7, 0x55, 0x4c, 0x72, 0xee, 0x10, 0xc3, 0x03, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26, 0x39, 0x77, 0x88, 0xc9, 0x01, 0x50, 0xb5, 0x7a,
0xa0, 0xca, 0xf5, 0xc2, 0x53, 0x73, 0x72, 0xbc, 0xf3, 0xf2, 0xcb, 0xf3, 0x42, 0x40, 0xda, 0x92, 0xe1, 0xa9, 0x39, 0x39, 0xde, 0x79, 0xf9, 0xe5, 0x79, 0x21, 0x20, 0x3d, 0x49, 0x6c, 0x60, 0x43,
0xd8, 0xc0, 0xe6, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x5f, 0xb7, 0xdc, 0x17, 0x01, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x77, 0x4a, 0x07, 0xf7, 0x00, 0x00, 0x00,
0x00, 0x00,
} }

View File

@ -38,7 +38,6 @@ option go_package = "github.com/golang/protobuf/ptypes/timestamp";
option java_package = "com.google.protobuf"; option java_package = "com.google.protobuf";
option java_outer_classname = "TimestampProto"; option java_outer_classname = "TimestampProto";
option java_multiple_files = true; option java_multiple_files = true;
option java_generate_equals_and_hash = true;
option objc_class_prefix = "GPB"; option objc_class_prefix = "GPB";
// A Timestamp represents a point in time independent of any time zone // A Timestamp represents a point in time independent of any time zone
@ -53,6 +52,8 @@ option objc_class_prefix = "GPB";
// and from RFC 3339 date strings. // and from RFC 3339 date strings.
// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).
// //
// # Examples
//
// Example 1: Compute Timestamp from POSIX `time()`. // Example 1: Compute Timestamp from POSIX `time()`.
// //
// Timestamp timestamp; // Timestamp timestamp;
@ -90,16 +91,37 @@ option objc_class_prefix = "GPB";
// //
// Example 5: Compute Timestamp from current time in Python. // Example 5: Compute Timestamp from current time in Python.
// //
// now = time.time() // timestamp = Timestamp()
// seconds = int(now) // timestamp.GetCurrentTime()
// nanos = int((now - seconds) * 10**9) //
// timestamp = Timestamp(seconds=seconds, nanos=nanos) // # JSON Mapping
//
// In JSON format, the Timestamp type is encoded as a string in the
// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
// where {year} is always expressed using four digits while {month}, {day},
// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
// is required, though only UTC (as indicated by "Z") is presently supported.
//
// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
// 01:30 UTC on January 15, 2017.
//
// In JavaScript, one can convert a Date object to this format using the
// standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
// method. In Python, a standard `datetime.datetime` object can be converted
// to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
// with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
// can use the Joda Time's [`ISODateTimeFormat.dateTime()`](
// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime())
// to obtain a formatter capable of generating timestamps in this format.
// //
// //
message Timestamp { message Timestamp {
// Represents seconds of UTC time since Unix epoch // Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive. // 9999-12-31T23:59:59Z inclusive.
int64 seconds = 1; int64 seconds = 1;