Versions in this module Expand all Collapse all v0 v0.1.0 Oct 20, 2026 Changes in this version + const KeyDoubleElimination + const KeyFFALeague + const KeyGroupStage + const KeyMultiStage + const KeyRoundRobin + const KeySingleElimination + const KeySwiss + const PlaceholderPrefix + var ErrInvalidOptions = errors.New("brackets: invalid options") + var ErrInvalidParticipant = errors.New("brackets: invalid participant") + var ErrInvalidResult = errors.New("brackets: invalid result") + var ErrInvalidStage = errors.New("brackets: invalid stage") + var ErrMatchNotFound = errors.New("brackets: match not found") + var ErrParticipantCount = errors.New("brackets: unsupported number of participants") + var ErrUnknownFormat = errors.New("brackets: unknown format") + func DefaultSwissRounds(n int) int + func FillPlaceholders(st *Stage, source string, qualifiers []string) int + func GroupName(i int) string + func GroupStandings(st *Stage) [][]Standing + func IsPlaceholder(ref string) bool + func NextPowerOfTwo(n int) int + func Placeholder(stage string, rank int) string + func Qualifiers(st *Stage, n int) []string + func SeedOrder(size int) []int + type Advance struct + CurrentRound int + Finished bool + NewByes []Bye + NewMatches []Match + Scoreboard map[string]int + Standings []Standing + Updates []SlotUpdate + Winner string + func Report(f Format, st *Stage, matchID string, r Result) (*Advance, error) + func ReportAt(f Format, st *Stage, i int, r Result) (*Advance, error) + type Bracket uint8 + const GrandFinal + const LowerBracket + const NoBracket + const UpperBracket + func (b Bracket) String() string + type Bye struct + Participant string + Round int + type CountError struct + Format string + Got int + Need int + Rule CountRule + func (e *CountError) Error() string + func (e *CountError) Unwrap() error + type CountRule uint8 + const AtLeast + const MultipleOf + const NoPlayableMatches + const PowerOfTwo + type DoubleElimination struct + func (DoubleElimination) Key() string + func (DoubleElimination) Moves(finished *Match) Moves + func (DoubleElimination) Plan(participants []Participant, opts Options) ([]Stage, error) + func (DoubleElimination) Validate(Options) error + func (f DoubleElimination) Advance(st *Stage, finished *Match) (*Advance, error) + type FFALeague struct + func (FFALeague) Advance(st *Stage, _ *Match) (*Advance, error) + func (FFALeague) Key() string + func (FFALeague) Plan(participants []Participant, opts Options) ([]Stage, error) + func (FFALeague) Validate(opts Options) error + type Format interface + Advance func(stage *Stage, finished *Match) (*Advance, error) + Key func() string + Plan func(participants []Participant, opts Options) ([]Stage, error) + Validate func(opts Options) error + type Group struct + Name string + Participants []string + type GroupStage struct + func (GroupStage) Advance(st *Stage, _ *Match) (*Advance, error) + func (GroupStage) Key() string + func (GroupStage) Plan(participants []Participant, opts Options) ([]Stage, error) + func (GroupStage) Validate(opts Options) error + type Link struct + Index int + Match string + Slot int + type LinkError struct + From string + Number int + Round int + Target string + func (e *LinkError) Error() string + func (e *LinkError) Unwrap() error + type Match struct + BestOf int + Bracket Bracket + BracketRound int + Bye bool + Elimination bool + From []string + Group string + GroupIndex int + ID string + Leg int + LobbyRound int + LoserTo *Link + Number int + Partial bool + Phantom bool + Round int + Size int + Slots []Slot + Status Status + Winner string + WinnerTo *Link + func (m *Match) Away() string + func (m *Match) Has(id string) bool + func (m *Match) Home() string + func (m *Match) Loser() string + func (m *Match) LoserSlot() int + type Moves struct + Final bool + Loser string + LoserSlot int + LoserTo *Link + Winner string + WinnerTo *Link + type MultiStage struct + func (MultiStage) Advance(st *Stage, finished *Match) (*Advance, error) + func (MultiStage) Key() string + func (MultiStage) Plan(participants []Participant, opts Options) ([]Stage, error) + func (MultiStage) Validate(opts Options) error + type OptionError struct + Field string + Format string + Reason string + func (e *OptionError) Error() string + func (e *OptionError) Unwrap() error + type Options struct + Advances int + AdvancesPerGroup int + GroupSize int + Legs int + LobbyRounds int + MatchSize int + Name string + Pairing Pairing + Partial PartialPolicy + Rand rand.Source + Rounds int + Seed uint64 + Seeding Seeding + Shuffle bool + Stages []StageSpec + Strict bool + TargetPoints int + type Pairing uint8 + const AvoidRematches + const Greedy + type PartialPolicy uint8 + const PartialAllow + const PartialAuto + const PartialDeny + type Participant struct + ID string + Seed int + func SortParticipants(ps []Participant) []Participant + type ParticipantError struct + ID string + Reason string + func (e *ParticipantError) Error() string + func (e *ParticipantError) Unwrap() error + type Registry struct + func DefaultRegistry() *Registry + func NewRegistry(formats ...Format) *Registry + func (r *Registry) Get(key string) (Format, error) + func (r *Registry) Keys() []string + func (r *Registry) Register(key string, f Format) + type Result struct + Placements []int + Points []int + Scores []int + Winner string + type RoundRobin struct + func (RoundRobin) Advance(st *Stage, _ *Match) (*Advance, error) + func (RoundRobin) Key() string + func (RoundRobin) Validate(opts Options) error + func (f RoundRobin) Plan(participants []Participant, opts Options) ([]Stage, error) + type Seeding uint8 + const Sequential + const Snake + func (s Seeding) String() string + type SingleElimination struct + func (SingleElimination) Advance(st *Stage, finished *Match) (*Advance, error) + func (SingleElimination) Key() string + func (SingleElimination) Parent(round, number int) (nextRound, nextNumber, slot int) + func (SingleElimination) Plan(participants []Participant, opts Options) ([]Stage, error) + func (SingleElimination) Validate(Options) error + type Slot struct + HasPoints bool + ID string + Placeholder string + Placement int + Points int + Score int + func (s Slot) Ref() string + type SlotUpdate struct + Index int + Match string + Participant string + Slot int + type Stage struct + Byes []Bye + CurrentRound int + Finished bool + Format string + Groups []Group + Key string + LowerRounds int + Matches []Match + Name string + Options Options + Order int + Participants []string + Rounds int + Scoreboard map[string]int + SeedOrder []int + Size int + Source string + SourceCount int + Standings []Standing + Type string + UpperRounds int + UpperSize int + Winner string + func (s *Stage) Apply(a *Advance) + func (s *Stage) Match(id string) *Match + type StageError struct + Err error + Stage string + func (e *StageError) Error() string + func (e *StageError) Unwrap() error + type StageSpec struct + Key string + Name string + Options Options + Source string + Take int + Type string + type Standing struct + Byes int + Draws int + ID string + Losses int + Order int + Played int + PointsAgainst int + PointsFor int + Rank int + Wins int + func Standings(st *Stage) []Standing + func (s *Standing) Diff() int + type Status uint8 + const Cancelled + const Finished + const Live + const Pending + func (s Status) Resolved() bool + func (s Status) String() string + type Swiss struct + func (Swiss) AdvanceTally(st *Stage, t *Tally) (*Advance, error) + func (Swiss) Key() string + func (Swiss) Validate(opts Options) error + func (f Swiss) Advance(st *Stage, _ *Match) (*Advance, error) + func (f Swiss) Plan(participants []Participant, opts Options) ([]Stage, error) + type Tally struct + func NewTally(participants []string, byes []Bye) *Tally + func (t *Tally) Add(m *Match) + func (t *Tally) AllResolved() bool + func (t *Tally) Grow(n int) + func (t *Tally) MaxRound() int + func (t *Tally) RoundResolved(r int) bool + func (t *Tally) Standings() []Standing