parkrunparser

package module
v0.0.0-...-c7686d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 7 Imported by: 2

README

PkgGoDev Go Report Card License MIT

go-parkrunparser

A Go module to parse various parkrun webpages

  • events.json -> func ParseEvents(buf []byte) (Events, error)
  • eventshistory -> func ParseEventHistory(buf []byte) (EventHistory, error)
  • results/123, latestresults -> func ParseResults(buf []byte) (Results, error)

Note: the package will not download any files from the parkrun webpage!

Users

go-parkrunparser is currently used by

Documentation

Index

Constants

View Source
const (
	SEX_UNKNOWN = iota
	SEX_FEMALE
	SEX_MALE
)

Variables

This section is empty.

Functions

func ParseDate

func ParseDate(s string) (time.Time, error)

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

Types

type Achievement

type Achievement int
const (
	AchievementNone Achievement = iota
	AchievementFirst
	AchievementPB
)

func ParseAchievement

func ParseAchievement(s string) (Achievement, error)

type AgeGroup

type AgeGroup struct {
	Name string
	Age  string
	Sex  Sex
}

func ParseAgeGroup

func ParseAgeGroup(s string) (AgeGroup, error)

type Country

type Country struct {
	Url    string
	Bounds []LatLng
	Events []*Event
}

func (Country) Name

func (c Country) Name() string

type Event

type Event struct {
	Name        string
	LongName    string
	ShortName   string
	Location    string
	Coordinates LatLng
	Country     *Country
	Type        EventType
}

func (Event) Url

func (e Event) Url() string

type EventHistory

type EventHistory struct {
	Results []*Results
}

func ParseEventHistory

func ParseEventHistory(buf []byte) (EventHistory, error)

type EventType

type EventType int
const (
	EVENTTYPE_REGULAR EventType = iota
	EVENTTYPE_JUNIOR
)

type Events

type Events struct {
	Countries []*Country
	Events    []*Event
}

func ParseEvents

func ParseEvents(data []byte) (Events, error)

type Finisher

type Finisher struct {
	*Parkrunner
	AgeGroup              AgeGroup
	Time                  time.Duration
	Achievement           Achievement
	NumberOfRuns          int
	NumberOfVolunteerings int
}

func (Finisher) IsUnknown

func (f Finisher) IsUnknown() bool

type JCountry

type JCountry struct {
	Url    string    `json:"url"`
	Bounds []float64 `json:"bounds"`
}

type JEvents

type JEvents struct {
	Type     string     `json:"type"`
	Features []JFeature `json:"features"`
}

type JEventsJson

type JEventsJson struct {
	Counties map[string]JCountry `json:"countries"`
	Events   JEvents             `json:"events"`
}

type JFeature

type JFeature struct {
	Id         int         `json:"id"`
	Type       string      `json:"type"`
	Geometry   JGeometry   `json:"geometry"`
	Properties JProperties `json:"properties"`
}

type JGeometry

type JGeometry struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

type JProperties

type JProperties struct {
	Name              string `json:"eventname"`
	LongName          string `json:"EventLongName"`
	ShortName         string `json:"EventShortName"`
	LocalizedLongName string `json:"LocalisedEventLongName"`
	CountryCode       int    `json:"countrycode"`
	SeriesId          int    `json:"seriesid"`
	Location          string `json:"EventLocation"`
}

type LatLng

type LatLng struct {
	Lat, Lng float64
}

type Parkrunner

type Parkrunner struct {
	Id   string
	Name string
}

func (Parkrunner) IsUnknown

func (p Parkrunner) IsUnknown() bool

type Results

type Results struct {
	Index              int
	Date               time.Time
	NumberOfFinishers  int
	NumberOfVolunteers int
	Finishers          []Finisher
	Volunteers         []Parkrunner
}

func ParseResults

func ParseResults(buf []byte) (Results, error)

type Sex

type Sex int

func (Sex) String

func (s Sex) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL