Documentation
¶
Index ¶
- Constants
- Variables
- type Date
- type Duration
- func (d *Duration) Bind(src string) error
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d Duration) MarshalText() ([]byte, error)
- func (d Duration) String() string
- func (d Duration) TimeDuration() (time.Duration, error)
- func (d *Duration) UnmarshalJSON(data []byte) error
- func (d *Duration) UnmarshalText(data []byte) error
- type Email
- type File
- func (file File) Bytes() ([]byte, error)
- func (file File) FileSize() int64
- func (file File) Filename() string
- func (file *File) InitFromBytes(data []byte, filename string)
- func (file *File) InitFromMultipart(header *multipart.FileHeader)
- func (file File) MarshalJSON() ([]byte, error)
- func (file File) Reader() (io.ReadCloser, error)
- func (file *File) UnmarshalJSON(data []byte) error
- type UUID
Constants ¶
const DateFormat = "2006-01-02"
Variables ¶
var ErrValidationEmail = errors.New("email: failed to pass regex validation")
ErrValidationEmail is the sentinel error returned when an email fails validation
Functions ¶
This section is empty.
Types ¶
type Date ¶
func (*Date) Bind ¶ added in v1.2.0
Bind implements the runtime.Binder interface so that Date is treated as a scalar value when binding query parameters rather than being decomposed as a struct with key-value pairs.
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
func (*Date) UnmarshalText ¶
type Duration ¶ added in v1.5.0
type Duration struct {
Years int
Months int
Weeks int
Days int
Hours int
Minutes int
// Seconds may carry a fraction (e.g. "PT0.5S"). Strictly, RFC 3339
// allows only integer components; ISO 8601 permits a fraction on the
// smallest component, and real-world payloads use it, so fractional
// seconds are accepted when parsing and emitted when present.
Seconds float64
}
Duration represents an RFC 3339 duration (the ISO 8601 duration grammar referenced by the OpenAPI "duration" format), e.g. "P3Y6M4DT12H30M5S". See https://spec.openapis.org/registry/format/duration
Calendar components (years, months, weeks, days) have no fixed length in wall-clock time, so the components are stored as parsed instead of being converted to a time.Duration; any spec-valid duration round-trips losslessly through ParseDuration and String. Use TimeDuration and FromTimeDuration to bridge to time.Duration where the conversion is well-defined.
The RFC 3339 grammar makes weeks exclusive ("P2W" cannot be combined with other components); ParseDuration enforces that, but the struct cannot. A hand-built value mixing Weeks with other components serializes with the week between the months and days, which is outside the strict grammar.
func FromTimeDuration ¶ added in v1.5.0
FromTimeDuration decomposes a time.Duration into hours, minutes and seconds. RFC 3339 durations cannot be negative, so a negative input is an error.
func ParseDuration ¶ added in v1.5.0
ParseDuration parses an RFC 3339 duration string per the grammar in RFC 3339 appendix A: "P" followed by ordered date components ("1Y2M3D"), a time part introduced by "T" ("T4H5M6S"), or a standalone week component ("2W"). At least one component must be present. As an interoperability extension beyond the strict grammar, the seconds component may carry a fraction, with either a period or a comma ("PT0.5S", "PT0,5S").
func (*Duration) Bind ¶ added in v1.5.0
Bind implements the runtime.Binder interface so that Duration is treated as a scalar value when binding parameters rather than being decomposed as a struct with key-value pairs.
func (Duration) MarshalJSON ¶ added in v1.5.0
func (Duration) MarshalText ¶ added in v1.5.0
func (Duration) String ¶ added in v1.5.0
String serializes the duration in RFC 3339 form, omitting zero components. The all-zero duration serializes as "PT0S".
func (Duration) TimeDuration ¶ added in v1.5.0
TimeDuration converts to a time.Duration. Years and months have no fixed length, so their presence is an error; weeks and days are converted with the common fixed convention of 7-day weeks and 24-hour days, which ignores calendar effects such as DST transitions.
func (*Duration) UnmarshalJSON ¶ added in v1.5.0
func (*Duration) UnmarshalText ¶ added in v1.5.0
type Email ¶
type Email string
Email represents an email address. It is a string type that must pass regex validation before being marshalled to JSON or unmarshalled from JSON.
func (Email) MarshalJSON ¶
func (*Email) UnmarshalJSON ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) InitFromBytes ¶
func (*File) InitFromMultipart ¶
func (file *File) InitFromMultipart(header *multipart.FileHeader)