catalog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalog finds a flag by a code known only at run time, such as a user's country, and lists every flag with its English name.

if f, ok := catalog.Find(region); ok {
	core.Icon{SVG: f.SVG(), Style: core.Style{FontSize: 24}, Label: f.Name}
}

Importing it links every flag in both ratios into the binary, about 4 MB; an app that knows its flags at build time calls package flags' accessors instead, and carries only those.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	// Code is upstream's lowercase code: an ISO 3166-1 alpha-2 code such as "jp", a subdivision such as "gb-sct", or an organization such as "eu".
	Code string
	// Name is the English name, such as "Japan".
	Name string
	// Capital and Continent are empty where upstream records none.
	Capital, Continent string
	// ISO reports whether Code is an ISO 3166-1 alpha-2 code.
	ISO bool
	// contains filtered or unexported fields
}

Flag is one flag and what upstream records about it.

func All

func All() []Flag

All returns every flag, sorted by English name. The slice is the caller's.

func Find

func Find(code string) (Flag, bool)

Find returns the flag for code, ignoring case and surrounding space, so "JP" and "gb-SCT" are found. A region from a locale, such as the "GB" of "en-GB", is a code it takes.

func (Flag) SVG

func (f Flag) SVG() *core.SVG

SVG returns the 4:3 flag, parsed once and shared. It is nil for the zero Flag.

func (Flag) Square

func (f Flag) Square() *core.SVG

Square returns the 1:1 flag, parsed once and shared. It is nil for the zero Flag.

Jump to

Keyboard shortcuts

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