Skip to content

Commit eccd77d

Browse files
authoredMar 3, 2021
ptypes: deprecate the package (#1217)
Deprecate the ptypes package since all the equivalent functionality is now directly generated with the well-known types themselves.
1 parent 4846b58 commit eccd77d

File tree

6 files changed

+82
-5
lines changed

6 files changed

+82
-5
lines changed
 

‎go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module github.com/golang/protobuf
33
go 1.9
44

55
require (
6-
github.com/google/go-cmp v0.4.0
7-
google.golang.org/protobuf v1.23.0
6+
github.com/google/go-cmp v0.5.0
7+
google.golang.org/protobuf v1.25.0
88
)

‎go.sum

+49-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,64 @@
1+
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3+
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
4+
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
5+
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
6+
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
7+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
8+
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
9+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
10+
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
111
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
212
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
313
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
414
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
515
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
16+
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
17+
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
618
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
719
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
8-
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
920
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
21+
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
22+
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
23+
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
24+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
25+
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
26+
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
27+
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
28+
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
29+
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
30+
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
31+
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
32+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
33+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
34+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
35+
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
36+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
37+
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
38+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
39+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
40+
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
41+
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
42+
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
43+
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
1044
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
1145
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
46+
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
47+
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
48+
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
49+
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
50+
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
51+
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
52+
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
53+
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
1254
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
1355
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
1456
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
1557
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
1658
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
17-
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
18-
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
59+
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
60+
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
61+
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
62+
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
63+
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
64+
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

‎ptypes/any.go

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const urlPrefix = "type.googleapis.com/"
1919

2020
// AnyMessageName returns the message name contained in an anypb.Any message.
2121
// Most type assertions should use the Is function instead.
22+
//
23+
// Deprecated: Call the any.MessageName method instead.
2224
func AnyMessageName(any *anypb.Any) (string, error) {
2325
name, err := anyMessageName(any)
2426
return string(name), err
@@ -38,6 +40,8 @@ func anyMessageName(any *anypb.Any) (protoreflect.FullName, error) {
3840
}
3941

4042
// MarshalAny marshals the given message m into an anypb.Any message.
43+
//
44+
// Deprecated: Call the anypb.New function instead.
4145
func MarshalAny(m proto.Message) (*anypb.Any, error) {
4246
switch dm := m.(type) {
4347
case DynamicAny:
@@ -58,6 +62,9 @@ func MarshalAny(m proto.Message) (*anypb.Any, error) {
5862
// Empty returns a new message of the type specified in an anypb.Any message.
5963
// It returns protoregistry.NotFound if the corresponding message type could not
6064
// be resolved in the global registry.
65+
//
66+
// Deprecated: Use protoregistry.GlobalTypes.FindMessageByName instead
67+
// to resolve the message name and create a new instance of it.
6168
func Empty(any *anypb.Any) (proto.Message, error) {
6269
name, err := anyMessageName(any)
6370
if err != nil {
@@ -76,6 +83,8 @@ func Empty(any *anypb.Any) (proto.Message, error) {
7683
//
7784
// The target message m may be a *DynamicAny message. If the underlying message
7885
// type could not be resolved, then this returns protoregistry.NotFound.
86+
//
87+
// Deprecated: Call the any.UnmarshalTo method instead.
7988
func UnmarshalAny(any *anypb.Any, m proto.Message) error {
8089
if dm, ok := m.(*DynamicAny); ok {
8190
if dm.Message == nil {
@@ -100,6 +109,8 @@ func UnmarshalAny(any *anypb.Any, m proto.Message) error {
100109
}
101110

102111
// Is reports whether the Any message contains a message of the specified type.
112+
//
113+
// Deprecated: Call the any.MessageIs method instead.
103114
func Is(any *anypb.Any, m proto.Message) bool {
104115
if any == nil || m == nil {
105116
return false
@@ -119,6 +130,9 @@ func Is(any *anypb.Any, m proto.Message) bool {
119130
// var x ptypes.DynamicAny
120131
// if err := ptypes.UnmarshalAny(a, &x); err != nil { ... }
121132
// fmt.Printf("unmarshaled message: %v", x.Message)
133+
//
134+
// Deprecated: Use the any.UnmarshalNew method instead to unmarshal
135+
// the any message contents into a new instance of the underlying message.
122136
type DynamicAny struct{ proto.Message }
123137

124138
func (m DynamicAny) String() string {

‎ptypes/doc.go

+4
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
// license that can be found in the LICENSE file.
44

55
// Package ptypes provides functionality for interacting with well-known types.
6+
//
7+
// Deprecated: Well-known types have specialized functionality directly
8+
// injected into the generated packages for each message type.
9+
// See the deprecation notice for each function for the suggested alternative.
610
package ptypes

‎ptypes/duration.go

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121

2222
// Duration converts a durationpb.Duration to a time.Duration.
2323
// Duration returns an error if dur is invalid or overflows a time.Duration.
24+
//
25+
// Deprecated: Call the dur.AsDuration and dur.CheckValid methods instead.
2426
func Duration(dur *durationpb.Duration) (time.Duration, error) {
2527
if err := validateDuration(dur); err != nil {
2628
return 0, err
@@ -39,6 +41,8 @@ func Duration(dur *durationpb.Duration) (time.Duration, error) {
3941
}
4042

4143
// DurationProto converts a time.Duration to a durationpb.Duration.
44+
//
45+
// Deprecated: Call the durationpb.New function instead.
4246
func DurationProto(d time.Duration) *durationpb.Duration {
4347
nanos := d.Nanoseconds()
4448
secs := nanos / 1e9

‎ptypes/timestamp.go

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const (
3333
//
3434
// A nil Timestamp returns an error. The first return value in that case is
3535
// undefined.
36+
//
37+
// Deprecated: Call the ts.AsTime and ts.CheckValid methods instead.
3638
func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
3739
// Don't return the zero value on error, because corresponds to a valid
3840
// timestamp. Instead return whatever time.Unix gives us.
@@ -46,6 +48,8 @@ func Timestamp(ts *timestamppb.Timestamp) (time.Time, error) {
4648
}
4749

4850
// TimestampNow returns a google.protobuf.Timestamp for the current time.
51+
//
52+
// Deprecated: Call the timestamppb.Now function instead.
4953
func TimestampNow() *timestamppb.Timestamp {
5054
ts, err := TimestampProto(time.Now())
5155
if err != nil {
@@ -56,6 +60,8 @@ func TimestampNow() *timestamppb.Timestamp {
5660

5761
// TimestampProto converts the time.Time to a google.protobuf.Timestamp proto.
5862
// It returns an error if the resulting Timestamp is invalid.
63+
//
64+
// Deprecated: Call the timestamppb.New function instead.
5965
func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
6066
ts := &timestamppb.Timestamp{
6167
Seconds: t.Unix(),
@@ -69,6 +75,9 @@ func TimestampProto(t time.Time) (*timestamppb.Timestamp, error) {
6975

7076
// TimestampString returns the RFC 3339 string for valid Timestamps.
7177
// For invalid Timestamps, it returns an error message in parentheses.
78+
//
79+
// Deprecated: Call the ts.AsTime method instead,
80+
// followed by a call to the Format method on the time.Time value.
7281
func TimestampString(ts *timestamppb.Timestamp) string {
7382
t, err := Timestamp(ts)
7483
if err != nil {

0 commit comments

Comments
 (0)
Please sign in to comment.