Does Goa support protobufs Timestamp data type? #3677
Answered
by
raphael
RedMarcher
asked this question in
Q&A
-
Protobufs has a timestamp data type, however I'm having a really hard time figuring out if goa api also supports such a thing. I can't find anything similar in the DSL so I'm not sure. |
Beta Was this translation helpful? Give feedback.
Answered by
raphael
Mar 26, 2025
Replies: 1 comment
-
The var Timestamp = Type("Timestamp", func() {
Description("Google timestamp compatible design")
Field(1, "seconds", Int64, "Unix timestamp in seconds", func() {
Meta("struct:field:proto", "int64") // Goa generates sint64 by default
})
Field(2, "nanos", Int32, "Unix timestamp in nanoseconds", func() {
Meta("struct:field:proto", "int32") // Goa generates sint32 by default
})
})
var MyType = Type("MyType", func() {
Field(1, "created_at", Timestamp, func() {
Meta("struct:field:proto", "google.protobuf.Timestamp", "google/protobuf/timestamp.proto", "Timestamp", "google.golang.org/protobuf/types/known/timestamppb")
})
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RedMarcher
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
Meta
function makes it possible to use types defined in external proto files, such as Google's timestamp type. Seestruct:field:proto
in the Meta documentation: