data

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package data provides utilities for loading mock football match data. MockMatches and MockMatchDetails are now in mock_matches.go and mock_details.go

Package data provides utilities for loading mock football match data.

Index

Constants

View Source
const (
	RegionEurope  = "Europe"
	RegionAmerica = "Americas"
	RegionGlobal  = "Global"
)

Region constants for organizing leagues

Variables

View Source
var AllSupportedLeagues = map[string][]LeagueInfo{
	RegionEurope: {

		{ID: 47, Name: "Premier League", Country: "England"},
		{ID: 87, Name: "La Liga", Country: "Spain"},
		{ID: 54, Name: "Bundesliga", Country: "Germany"},
		{ID: 55, Name: "Serie A", Country: "Italy"},
		{ID: 53, Name: "Ligue 1", Country: "France"},

		{ID: 9227, Name: "Women's Super League", Country: "England"},
		{ID: 9907, Name: "Liga F", Country: "Spain"},
		{ID: 9676, Name: "Frauen-Bundesliga", Country: "Germany"},
		{ID: 10178, Name: "Serie A Femminile", Country: "Italy"},
		{ID: 9667, Name: "Première Ligue Féminine", Country: "France"},

		{ID: 67, Name: "Allsvenskan", Country: "Sweden"},
		{ID: 38, Name: "Austrian Bundesliga", Country: "Austria"},
		{ID: 40, Name: "Belgian First Division", Country: "Belgium"},
		{ID: 48, Name: "EFL Championship", Country: "England"},
		{ID: 108, Name: "EFL League One", Country: "England"},
		{ID: 109, Name: "EFL League Two", Country: "England"},
		{ID: 196, Name: "Ekstraklasa", Country: "Poland"},
		{ID: 57, Name: "Eredivisie", Country: "Netherlands"},
		{ID: 218, Name: "League of Ireland First Division", Country: "Ireland"},
		{ID: 126, Name: "League of Ireland Premier Division", Country: "Ireland"},
		{ID: 61, Name: "Primeira Liga", Country: "Portugal"},
		{ID: 10215, Name: "Primeira Liga Qualification", Country: "Portugal"},
		{ID: 185, Name: "Liga Portugal 2", Country: "Portugal"},
		{ID: 9668, Name: "Liga Portugal 2 Qualification", Country: "Portugal"},
		{ID: 64, Name: "Scottish Premiership", Country: "Scotland"},
		{ID: 135, Name: "Super League 1", Country: "Greece"},
		{ID: 46, Name: "Superligaen", Country: "Denmark"},
		{ID: 71, Name: "Süper Lig", Country: "Turkey"},
		{ID: 69, Name: "Swiss Super League", Country: "Switzerland"},
		{ID: 63, Name: "Russian Premier League", Country: "Russia"},
		{ID: 441, Name: "Ukrainian Premier League", Country: "Ukraine"},

		{ID: 42, Name: "UEFA Champions League", Country: "Europe"},
		{ID: 10216, Name: "UEFA Conference League", Country: "Europe"},
		{ID: 73, Name: "UEFA Europa League", Country: "Europe"},
		{ID: 50, Name: "UEFA Euro", Country: "Europe"},
		{ID: 292, Name: "UEFA Women's Euro", Country: "Europe"},
		{ID: 9375, Name: "Women's UEFA Champions League", Country: "Europe"},

		{ID: 138, Name: "Copa del Rey", Country: "Spain"},
		{ID: 139, Name: "Supercopa de España", Country: "Spain"},
		{ID: 132, Name: "FA Cup", Country: "England"},
		{ID: 209, Name: "DFB Pokal", Country: "Germany"},
		{ID: 10650, Name: "Women's DFB Pokal", Country: "Germany"},
		{ID: 141, Name: "Coppa Italia", Country: "Italy"},
		{ID: 134, Name: "Coupe de France", Country: "France"},

		{ID: 186, Name: "Taça de Portugal", Country: "Portugal"},
		{ID: 187, Name: "Taça da Liga", Country: "Portugal"},
		{ID: 188, Name: "Supertaça Cândido de Oliveira", Country: "Portugal"},
	},
	RegionAmerica: {

		{ID: 268, Name: "Brasileirão Série A", Country: "Brazil"},
		{ID: 8814, Name: "Brasileirão Série B", Country: "Brazil"},
		{ID: 10274, Name: "Gaúcho", Country: "Brazil"},
		{ID: 44, Name: "Copa America", Country: "South America"},
		{ID: 9490, Name: "Copa Colombia", Country: "Colombia"},
		{ID: 45, Name: "Copa Libertadores", Country: "South America"},
		{ID: 299, Name: "Copa Sudamericana", Country: "South America"},
		{ID: 112, Name: "Liga Profesional", Country: "Argentina"},
		{ID: 274, Name: "Primera A", Country: "Colombia"},
		{ID: 9125, Name: "Primera B", Country: "Colombia"},
		{ID: 161, Name: "Primera Division", Country: "Uruguay"},
		{ID: 273, Name: "Primera Division", Country: "Chile"},
		{ID: 131, Name: "Liga 1", Country: "Peru"},
		{ID: 246, Name: "Serie A", Country: "Ecuador"},

		{ID: 130, Name: "MLS", Country: "USA"},
		{ID: 9134, Name: "NWSL", Country: "USA"},
		{ID: 230, Name: "Liga MX", Country: "Mexico"},
	},
	RegionGlobal: {

		{ID: 536, Name: "Saudi Pro League", Country: "Saudi Arabia"},

		{ID: 9478, Name: "Indian Super League", Country: "India"},
		{ID: 223, Name: "J. League", Country: "Japan"},
		{ID: 9080, Name: "K League 1", Country: "South Korea"},
		{ID: 9137, Name: "Chinese League One", Country: "China"},
		{ID: 535, Name: "Qatar Stars League", Country: "Qatar"},

		{ID: 113, Name: "A-League", Country: "Australia"},

		{ID: 519, Name: "Egyptian Premier League", Country: "Egypt"},
		{ID: 537, Name: "Premier Soccer League", Country: "South Africa"},
		{ID: 530, Name: "Botola Pro", Country: "Morocco"},

		{ID: 289, Name: "Africa Cup of Nations", Country: "International"},
		{ID: 77, Name: "FIFA World Cup", Country: "International"},
		{ID: 76, Name: "Women's FIFA World Cup", Country: "International"},
		{ID: 78, Name: "FIFA Club World Cup", Country: "International"},
		{ID: 9806, Name: "UEFA Nations League", Country: "International"},
		{ID: 489, Name: "Club Friendlies", Country: "International"},
		{ID: 114, Name: "International Friendlies", Country: "International"},
	},
}

AllSupportedLeagues contains all leagues that Golazo supports organized by region. This is the source of truth for available leagues.

View Source
var DefaultLeagueIDs = []int{
	47,
	87,
	42,
}

DefaultLeagueIDs contains the default leagues used when no selection is made. These are the most popular leagues for efficient API usage.

Functions

func ActiveLeagueIDs added in v0.11.0

func ActiveLeagueIDs() []int

ActiveLeagueIDs returns the league IDs that should be used for API calls. If no leagues are selected in settings, returns the default leagues (not all).

func AllLeagueIDs added in v0.11.0

func AllLeagueIDs() []int

AllLeagueIDs returns all supported league IDs (used as fallback).

func CacheDir added in v0.7.0

func CacheDir() (string, error)

CacheDir returns the path to the golazo cache directory. Uses os.UserCacheDir() which returns:

  • Linux: ~/.cache/golazo (or $XDG_CACHE_HOME/golazo)
  • macOS: ~/Library/Caches/golazo
  • Windows: %LocalAppData%/golazo

func CheckLatestVersion added in v0.12.0

func CheckLatestVersion() (string, error)

CheckLatestVersion fetches the latest version from GitHub releases. Uses GitHub's redirect URL which is simpler than the API. Returns the version tag (e.g., "v1.2.3").

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the path to the golazo config directory. On Linux, follows XDG Base Directory spec (~/.config/golazo). On other systems (macOS, Windows), uses ~/.golazo.

func GenerateRandomUpdate

func GenerateRandomUpdate(matchID int) string

GenerateRandomUpdate generates a random live update string.

func GetAllRegions added in v0.13.0

func GetAllRegions() []string

GetAllRegions returns a list of all available regions in order.

func LiveUpdates

func LiveUpdates(matchID int) ([]string, error)

LiveUpdates retrieves live updates for a match.

func LoadLatestVersion added in v0.12.0

func LoadLatestVersion() (string, error)

LoadLatestVersion reads the latest known version from storage. Returns empty string if file doesn't exist or can't be read.

func MockDataPath

func MockDataPath() (string, error)

MockDataPath returns the path to the mock data file.

func MockFinishedMatchDetails

func MockFinishedMatchDetails(matchID int) (*api.MatchDetails, error)

MockFinishedMatchDetails returns detailed match information for finished matches. These matches have rich event data for testing the "all events" view.

func MockFinishedMatches

func MockFinishedMatches() []api.Match

MockFinishedMatches returns finished matches for the stats view. 9 matches from preferred leagues: Premier League, La Liga, Champions League

func MockLiveMatches

func MockLiveMatches() []api.Match

MockLiveMatches returns live matches for the live matches view. 5 matches total: 3 ongoing with events, 2 just finished (showing "all events")

func MockMatchDetails

func MockMatchDetails(matchID int) (*api.MatchDetails, error)

MockMatchDetails returns detailed match information for a specific match ID. Handles both live matches (from MockLiveMatches) and finished matches.

func MockMatches

func MockMatches() ([]api.Match, error)

MockMatches returns multiple mock matches for testing. This is a legacy function that combines live and finished matches.

func SaveLatestVersion added in v0.12.0

func SaveLatestVersion(version string) error

SaveLatestVersion saves the latest version to storage.

func SaveLiveUpdate

func SaveLiveUpdate(matchID int, update string) error

SaveLiveUpdate appends a live update to the storage.

func SaveSettings added in v0.3.0

func SaveSettings(settings *Settings) error

SaveSettings writes settings to the settings.yaml file.

func SettingsPath added in v0.3.0

func SettingsPath() (string, error)

SettingsPath returns the path to the settings file.

func ShouldCheckVersion added in v0.12.0

func ShouldCheckVersion() bool

ShouldCheckVersion returns true if we should check for a new version. Checks if the latest_version.txt file is older than 24 hours.

Types

type LeagueInfo added in v0.3.0

type LeagueInfo struct {
	ID      int
	Name    string
	Country string
}

LeagueInfo contains league metadata for display purposes.

func GetLeaguesForRegion added in v0.13.0

func GetLeaguesForRegion(region string) []LeagueInfo

GetLeaguesForRegion returns all leagues for a specific region.

type LiveUpdate

type LiveUpdate struct {
	MatchID int
	Update  string
	Time    time.Time
}

LiveUpdate represents a single live update string.

type LiveUpdateGenerator

type LiveUpdateGenerator struct {
	// contains filtered or unexported fields
}

LiveUpdateGenerator generates mock live updates for a match.

func NewLiveUpdateGenerator

func NewLiveUpdateGenerator(matchID int) *LiveUpdateGenerator

NewLiveUpdateGenerator creates a new live update generator for a match.

func (*LiveUpdateGenerator) HasMore

func (g *LiveUpdateGenerator) HasMore() bool

HasMore returns true if there are more updates.

func (*LiveUpdateGenerator) NextUpdate

func (g *LiveUpdateGenerator) NextUpdate() (string, bool)

NextUpdate returns the next live update string.

type MockMatchesData

type MockMatchesData struct {
	Matches []api.Match `json:"matches"`
}

MockMatchesData contains multiple matches for testing. Uses api.Match directly to ensure single source of truth.

type Settings added in v0.3.0

type Settings struct {
	// SelectedLeagues contains the IDs of leagues the user wants to follow.
	// If empty, all supported leagues are used.
	SelectedLeagues []int `yaml:"selected_leagues"`
}

Settings represents user preferences stored in settings.yaml.

func LoadSettings added in v0.3.0

func LoadSettings() (*Settings, error)

LoadSettings reads settings from the settings.yaml file. Returns default settings (empty selection = all leagues) if file doesn't exist.

func (*Settings) IsLeagueSelected added in v0.3.0

func (s *Settings) IsLeagueSelected(leagueID int) bool

IsLeagueSelected checks if a league ID is in the selected list.

Jump to

Keyboard shortcuts

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