Ask Your Question
1

How can one import well-known types such as timestamp from google.golang.org/protobuf using Protobuf?

asked 2022-06-18 11:00:00 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-11-05 21:00:00 +0000

woof gravatar image

To import well-known types such as timestamp from google.golang.org/protobuf using Protobuf, you need to add the following line of code at the top of your protobuf file:

import "google/protobuf/timestamp.proto";

After that, you can use the timestamp type in your message definitions like this:

message MyMessage {
  google.protobuf.Timestamp created_at = 1;
}

Note that you also need to import any other well-known types that you want to use in your protobuf file. For example, if you want to use the duration type, you need to add the following line of code:

import "google/protobuf/duration.proto";
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-18 11:00:00 +0000

Seen: 11 times

Last updated: Nov 05 '22