regions

package module
v0.0.0-...-1e51fc4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 5 Imported by: 0

README

Regional data such as State & Province

The data in this repository is maintained and verified by the PKI Consortium.

Only official regions are permitted and the authorized source of information must be attributed so that this can be easily re-verified at by others.

Automated sources:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Country

type Country struct {
	Name     string    `yaml:",omitempty"`
	ISO3166  string    `yaml:"iso3166-1,omitempty"` // ISO 3166-1 country code
	Complete bool      `yaml:""`
	Comments string    `yaml:",omitempty"`
	Regions  []*Region `yaml:",omitempty"`
}

Country information

func (*Country) GetOrCreateRegion

func (c *Country) GetOrCreateRegion(regionName []string, codeName, codeValue string) *Region

GetOrCreateRegion based on the code identifier (e.g., iso3361) and value

func (*Country) GetRegion

func (c *Country) GetRegion(regionName, codeName, codeValue string) *Region

GetRegion returns a region by the code identifier (e.g., iso3361) and value

func (*Country) MarshalYAML

func (c *Country) MarshalYAML() (interface{}, error)

MarshalYAML is a custom mashaller to sort and restoring comments automatically

func (*Country) RemoveSource

func (c *Country) RemoveSource(source string) error

RemoveSource removes data attributed to a source

type Region

type Region struct {
	Codes map[string]string `yaml:",omitempty"` // ISO 3166-2 region code, EU identifier, etc
	Names []*RegionName     `yaml:",omitempty"`
}

Region hold the information about a region

func (*Region) Add

func (r *Region) Add(regionName, language, source, nameType string) error

Add a new region

func (*Region) MarshalYAML

func (r *Region) MarshalYAML() (interface{}, error)

MarshalYAML is a custom mashaller to sort and restoring comments automatically

func (*Region) RemoveSource

func (r *Region) RemoveSource(source string) error

RemoveSource removes regions attributed to a source

Matching is done based on a prefix, this allows to remove all sources from a given website.

Language attributions are not removed, when the region exists in other sources

When a region is attributed to multiple sources the region is retained and only the attribution to the removed source is removed.

func (*Region) String

func (r *Region) String() string

String returns the region name in English or the first name when no English name is present.

type RegionName

type RegionName struct {
	Name    string    `yaml:",omitempty"` // Normalized value
	Sources []*Source `yaml:",omitempty"`
}

RegionName holds the languages and sources of a region name

func (*RegionName) MarshalYAML

func (n *RegionName) MarshalYAML() (interface{}, error)

MarshalYAML is a custom mashaller to sort and restoring comments automatically

type Source

type Source struct {
	Name      string   `yaml:",omitempty"`
	Languages []string `yaml:",omitempty,flow"`
	Value     string   `yaml:",omitempty"` // Value as included in the source
	Type      string   `yaml:",omitempty"` // To indicate alternative or other non primary names

}

Source holds the original value and language

func (*Source) MarshalYAML

func (s *Source) MarshalYAML() (interface{}, error)

MarshalYAML is a custom mashaller to sort and restoring comments automatically

Directories

Path Synopsis
Code generated by go generate; DO NOT EDIT.
Code generated by go generate; DO NOT EDIT.
cmd

Jump to

Keyboard shortcuts

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