Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a wrapper for durationpb.Duration to provide custom marshaling for JSON and URL query strings.
It embeds durationpb.Duration and exposes the .AsDuration() method to easily convert to time.Duration.
Example:
customDur := duration.New(30 * time.Second) goDur := customDur.AsDuration()
func (*Duration) AsDuration ¶
AsDuration returns the underlying time.Duration value.
func (Duration) EncodeValues ¶
EncodeValues implements the [query.Encoder] interface by encoding the duration as a string, like "3.3s".
func (Duration) MarshalJSON ¶
MarshalJSON implements the [json.Marshaler] interface by marshalling the duration as a protobuf Duration.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements the [json.Unmarshaler] interface. It can parse a duration from the protobuf Duration.
Click to show internal directories.
Click to hide internal directories.