Documentation ¶
Index ¶
- func AppendIf(err error, field string, errs []error) []error
- func CheckConditionallyRequired(field string, value string) (errs []error)
- func CheckErrors(ent any) []error
- func CheckInArray(field string, value string, values ...string) []error
- func CheckInArrayInt[T int | int64](field string, value T, values ...T) []error
- func CheckInsideRange(field string, value float64, min float64, max float64) (errs []error)
- func CheckInsideRangeInt[T int | int64](field string, value T, min T, max T) (errs []error)
- func CheckPositive(field string, value float64) (errs []error)
- func CheckPositiveInt[T int | int64](field string, value T) (errs []error)
- func CheckPresent(field string, value string) (errs []error)
- func CheckWarnings(ent any) []error
- func FallbackDate(currentTime time.Time, startTime time.Time, endTime time.Time, ...) (time.Time, bool, error)
- func FirstError(errs ...error) error
- func FromCsv(val any, strv string) error
- func IsValidColor(color string) bool
- func IsValidCurrency(value string) bool
- func IsValidEmail(email string) bool
- func IsValidLanguage(value string) bool
- func IsValidTimezone(value string) (string, bool)
- func IsValidURL(url string) bool
- func ReflectCheckErrors(ent any) []error
- func ReflectUpdateKeys(emap *EntityMap, ent any) []error
- func RelativeDate(currentTime time.Time, relativeDateLabel string) (time.Time, error)
- func SecondsToString(secs int64) string
- func StringToSeconds(value string) (int64, error)
- func ToCsv(val any) (string, error)
- func TryCsv(val any) string
- func TrySetField(err error, field string) error
- type BaseEntity
- type Bool
- type CanReflectCheck
- type Clock
- type Color
- type Counts
- type Currency
- type CurrencyAmount
- type DatabaseEntity
- type Date
- type Email
- type Entity
- type EntityMap
- func (emap *EntityMap) Get(efn string, eid string) (string, bool)
- func (emap *EntityMap) GetEntity(ent Entity) (string, bool)
- func (emap *EntityMap) KeysFor(efn string) []string
- func (emap *EntityMap) Set(efn string, oldid string, newid string) error
- func (emap *EntityMap) SetEntity(ent Entity, oldid string, newid string) error
- func (emap *EntityMap) Update(other EntityMap)
- func (emap *EntityMap) UpdateKey(v canSet, efn string) error
- type EntityWithConditionalErrors
- type EntityWithErrors
- type EntityWithExtra
- type EntityWithID
- type EntityWithLoadErrors
- type EntityWithReferences
- type EntityWithWarnings
- type ErrorEntity
- type ExtraEntity
- type FeedVersionEntity
- type Float
- type Geometry
- type GeometryOption
- func (g GeometryOption[T]) FlatCoords() []float64
- func (g GeometryOption[T]) MarshalJSON() ([]byte, error)
- func (g *GeometryOption[T]) Scan(src interface{}) error
- func (g GeometryOption[T]) Stride() int
- func (g *GeometryOption[T]) UnmarshalJSON(data []byte) error
- func (g GeometryOption[T]) Value() (driver.Value, error)
- type Int
- type Ints
- type Key
- type Language
- type LineEntity
- type LineString
- type Map
- type MinEntity
- type MockClock
- type Option
- func (r Option[T]) Check() error
- func (r Option[T]) IsPresent() bool
- func (r Option[T]) IsValid() bool
- func (r *Option[T]) IsZero() bool
- func (r Option[T]) MarshalJSON() ([]byte, error)
- func (r *Option[T]) OrSet(v T)
- func (r Option[T]) Ptr() *T
- func (r *Option[T]) Scan(src interface{}) error
- func (r *Option[T]) Set(v T)
- func (r Option[T]) String() string
- func (r *Option[T]) UnmarshalJSON(v []byte) error
- func (r *Option[T]) Unset()
- func (r Option[T]) Value() (driver.Value, error)
- type Point
- type Polygon
- type RealClock
- type RouteType
- type Seconds
- func (r Seconds) HMS() (int, int, int)
- func (r Seconds) Int() int
- func (r Seconds) MarshalGQL(w io.Writer)
- func (r Seconds) MarshalJSON() ([]byte, error)
- func (r *Seconds) Scan(src interface{}) error
- func (r *Seconds) SetInt(v int)
- func (r Seconds) String() string
- func (r Seconds) ToCsv() string
- func (r *Seconds) UnmarshalGQL(v any) error
- func (r *Seconds) UnmarshalJSON(d []byte) error
- type String
- type Strings
- type Tags
- type Time
- type Timestamps
- type Timezone
- type Url
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckConditionallyRequired ¶
CheckPresent returns an error if a string is empty
func CheckErrors ¶
func CheckInArray ¶
CheckInArray returns an error if the value is not in the set of provided values.
func CheckInArrayInt ¶
CheckInArrayInt returns an error if the value is not in the set of provided values.
func CheckInsideRange ¶
CheckInsideRange returns an error if the value is outside of the specified range
func CheckInsideRangeInt ¶
CheckInsideRangeInt returns an error if the value is outside of the specified range
func CheckPositive ¶
CheckPositive returns an error if the value is non-negative
func CheckPositiveInt ¶
CheckPositiveInt returns an error if the value is non-negative
func CheckPresent ¶
CheckPresent returns an error if a string is empty
func CheckWarnings ¶
func FallbackDate ¶
func FallbackDate(currentTime time.Time, startTime time.Time, endTime time.Time, fallbackWeek time.Time) (time.Time, bool, error)
FallbackDate gets an equivalent day-of-week within fallbackWeek if currentTime is not with startTime/endTime bounds
func FirstError ¶
func IsValidCurrency ¶
IsValidCurrency check is valid currency
func IsValidTimezone ¶
IsValidTimezone check is valid timezone
func ReflectUpdateKeys ¶
func RelativeDate ¶
RelativeDate gets a date reltive to the provided time; currentTime should have timezone set.
func SecondsToString ¶
SecondsToString takes seconds-since-midnight and returns a GTFS-style time.
func StringToSeconds ¶
StringToSeconds parses a GTFS-style time and returns seconds since midnight.
func TrySetField ¶
Types ¶
type BaseEntity ¶
type BaseEntity struct { MinEntity LineEntity ExtraEntity ErrorEntity DatabaseEntity FeedVersionEntity Timestamps }
type CanReflectCheck ¶
type Counts ¶
Counts is a simple map[string]int with json support
func (Counts) MarshalGQL ¶
func (*Counts) UnmarshalGQL ¶
type Currency ¶
func NewCurrency ¶
type CurrencyAmount ¶
func NewCurrencyAmount ¶
func NewCurrencyAmount(v float64) CurrencyAmount
func (*CurrencyAmount) SetCurrency ¶
func (r *CurrencyAmount) SetCurrency(value string) error
func (CurrencyAmount) ToCsv ¶
func (r CurrencyAmount) ToCsv() string
type DatabaseEntity ¶
type DatabaseEntity struct {
ID int `csv:"-"`
}
type Date ¶
Date is a nullable date
func (Date) MarshalGQL ¶
func (Date) MarshalJSON ¶
func (*Date) UnmarshalGQL ¶
type EntityMap ¶
type EntityMap struct {
// contains filtered or unexported fields
}
EntityMap stores correspondances between Entity IDs, e.g. StopID -> Stop's integer ID in a database.
type EntityWithConditionalErrors ¶
type EntityWithConditionalErrors interface {
ConditionalErrors() []error
}
type EntityWithErrors ¶
type EntityWithErrors interface {
Errors() []error
}
type EntityWithExtra ¶
type EntityWithID ¶
type EntityWithID interface {
GetID() int
}
type EntityWithLoadErrors ¶
type EntityWithReferences ¶
type EntityWithWarnings ¶
type EntityWithWarnings interface {
Warnings() []error
}
type ErrorEntity ¶
type ErrorEntity struct {
// contains filtered or unexported fields
}
func (*ErrorEntity) AddError ¶
func (ent *ErrorEntity) AddError(err error)
AddError adds a loading error to the entity, e.g. from a CSV parse failure
func (*ErrorEntity) LoadErrors ¶
func (ent *ErrorEntity) LoadErrors() []error
func (*ErrorEntity) LoadWarnings ¶
func (ent *ErrorEntity) LoadWarnings() []error
type ExtraEntity ¶
type ExtraEntity struct {
// contains filtered or unexported fields
}
func (*ExtraEntity) ClearExtra ¶
func (ent *ExtraEntity) ClearExtra()
func (*ExtraEntity) ExtraKeys ¶
func (ent *ExtraEntity) ExtraKeys() []string
func (*ExtraEntity) SetExtra ¶
func (ent *ExtraEntity) SetExtra(key string, value string)
SetExtra adds a string key, value pair to the entity's extra fields.
type FeedVersionEntity ¶
type FeedVersionEntity struct {
FeedVersionID int `csv:"-"`
}
func (*FeedVersionEntity) GetFeedVersionID ¶
func (ent *FeedVersionEntity) GetFeedVersionID() int
GetFeedVersionID returns the Entity's FeedVersionID.
func (*FeedVersionEntity) SetFeedVersionID ¶
func (ent *FeedVersionEntity) SetFeedVersionID(fvid int)
SetFeedVersionID sets the Entity's FeedVersionID.
type Geometry ¶
type Geometry struct { GeometryOption[geom.T] }
func NewGeometry ¶
func (Geometry) MarshalGQL ¶
func (*Geometry) UnmarshalGQL ¶
type GeometryOption ¶
Point is an EWKB/SL encoded point
func NewGeometryOption ¶
func NewGeometryOption[T geom.T](v T) GeometryOption[T]
func (GeometryOption[T]) FlatCoords ¶
func (g GeometryOption[T]) FlatCoords() []float64
func (GeometryOption[T]) MarshalJSON ¶
func (g GeometryOption[T]) MarshalJSON() ([]byte, error)
func (*GeometryOption[T]) Scan ¶
func (g *GeometryOption[T]) Scan(src interface{}) error
func (GeometryOption[T]) Stride ¶
func (g GeometryOption[T]) Stride() int
func (*GeometryOption[T]) UnmarshalJSON ¶
func (g *GeometryOption[T]) UnmarshalJSON(data []byte) error
type LineEntity ¶
type LineEntity struct {
// contains filtered or unexported fields
}
func (LineEntity) Line ¶
func (ent LineEntity) Line() int
func (*LineEntity) SetLine ¶
func (ent *LineEntity) SetLine(line int)
type LineString ¶
type LineString struct { GeometryOption[*geom.LineString] }
LineString is an EWKB/SL encoded LineString
func NewLineString ¶
func NewLineString(v *geom.LineString) LineString
func NewLineStringFromFlatCoords ¶
func NewLineStringFromFlatCoords(coords []float64) LineString
NewLineStringFromFlatCoords returns a new LineString from flat (3) coordinates
func (LineString) MarshalGQL ¶
func (r LineString) MarshalGQL(w io.Writer)
func (LineString) ToLineM ¶
func (g LineString) ToLineM() tlxy.LineM
func (LineString) ToPoints ¶
func (g LineString) ToPoints() []tlxy.Point
func (*LineString) UnmarshalGQL ¶
func (r *LineString) UnmarshalGQL(v any) error
type Map ¶
Map helps read and write map[string]any as JSON
func (Map) MarshalGQL ¶
func (*Map) UnmarshalGQL ¶
type Point ¶
type Point struct { GeometryOption[*geom.Point] }
Point is an EWKB/SL encoded point
func (Point) MarshalGQL ¶
func (*Point) UnmarshalGQL ¶
type Polygon ¶
type Polygon struct { GeometryOption[*geom.Polygon] }
Polygon is an EWKB/SL encoded Polygon
func NewPolygon ¶
func (Polygon) MarshalGQL ¶
func (*Polygon) UnmarshalGQL ¶
type RouteType ¶
type RouteType struct { Code int `json:"code"` Name string `json:"name"` Category string `json:"category"` Parent int `json:"parent"` }
RouteType contains details on each possible route_type
func GetBasicRouteType ¶
GetBasicRouteType returns the closest approximate basic route_type for an extended route_type.
func GetRouteType ¶
GetRouteType returns the details for a given route_type value.
type Seconds ¶
func NewSeconds ¶
func NewSecondsFromString ¶
func (Seconds) MarshalGQL ¶
func (Seconds) MarshalJSON ¶
func (*Seconds) UnmarshalGQL ¶
func (*Seconds) UnmarshalJSON ¶
type Strings ¶
Strings helps read and write []String as JSON
func NewStrings ¶
func (Strings) MarshalGQL ¶
func (*Strings) UnmarshalGQL ¶
type Tags ¶
Tags is a map[string]string with json and gql marshal support. This is a struct instead of bare map[string]string because of a gqlgen issue.
func (Tags) MarshalGQL ¶
func (*Tags) UnmarshalGQL ¶
type Time ¶
Time is a nullable date without time component
func (Time) MarshalGQL ¶
func (*Time) UnmarshalGQL ¶
type Timestamps ¶
Timestamps .
func (*Timestamps) UpdateTimestamps ¶
func (ent *Timestamps) UpdateTimestamps()
UpdateTimestamps initializes or updates CreatedAt / UpdatedAt