csvlocode

package
v0.42.11 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option sets an optional parameter of Table.

func WithExtraPaths

func WithExtraPaths(ps ...string) Option

WithExtraPaths returns an option to add extra paths to UN/LOCODE tables in csv format.

type Prm

type Prm struct {
	// Path to UN/LOCODE csv table.
	//
	// Must not be empty.
	Path string

	// Path to csv table of UN/LOCODE Subdivisions.
	//
	// Must not be empty.
	SubDivPath string
}

Prm groups the required parameters of the Table's constructor.

All values must comply with the requirements imposed on them. Passing incorrect parameter values will result in constructor failure (error or panic depending on the implementation).

type Table

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

Table is a descriptor of the UN/LOCODE table in csv format.

For correct operation, Table must be created using the constructor (New) based on the required parameters and optional components. After successful creation, The Table is immediately ready to work through API.

func New

func New(prm Prm, opts ...Option) *Table

New creates a new instance of the Table.

Panics if at least one value of the parameters is invalid.

The created Table does not require additional initialization and is completely ready for work.

func (*Table) IterateAll

func (t *Table) IterateAll(f func(locode.Record) error) error

IterateAll scans a table record one-by-one, parses a UN/LOCODE record from it and passes it to f.

Returns f's errors directly.

func (*Table) SubDivName

func (t *Table) SubDivName(countryCode *locodedb.CountryCode, code string) (string, error)

SubDivName scans a table record to an in-memory table (once), and returns the subdivision name of the country and the subdivision codes match.

Returns locodedb.ErrSubDivNotFound if no entry matches.

Jump to

Keyboard shortcuts

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