Reputation: 145
I want to use timestamppb
package in my protobufs
because it helps to easily convert Timestamp
to Go
time. Time
. However, I can't figure out how to import it into the .proto
file. When I try I get the following error Import "google.golang.org/protobuf/types/known/timestamppb" was not found or had errors.
I looked at the documentation timestamppb docs for the timestamppb
package but it seems there are no examples of how to use it in .proto
files.
syntax = "proto3";
import "google.golang.org/protobuf/types/known/timestamppb";
// import "google.golang.org/protobuf/types/known/timestamppb.proto"; I tried this too but no luck
message Example {
timestamppb.Timestamp example_time = 1;
}
Upvotes: 2
Views: 1078
Reputation: 2192
The import for .proto
files is:
import "google/protobuf/timestamp.proto";
The one that you tried is the path that is needed in Go Code in combination with go get
.
Upvotes: 3