Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a descriptor of the OpenFlights database in csv format.
For correct operation, DB must be created using the constructor (New) based on the required parameters and optional components. After successful creation, The DB is immediately ready to work through API.
func New ¶
New creates a new instance of the DB.
Panics if at least one value of the parameters is invalid.
The created DB does not require additional initialization and is completely ready for work.
func (*DB) CountryName ¶
func (db *DB) CountryName(code *locodedb.CountryCode) (name string, err error)
CountryName scans the records of the OpenFlights Country table to an in-memory table (once), and returns the name of the country by code.
Returns locodedb.ErrCountryNotFound if no entry matches.
func (*DB) Get ¶
Get scans the records of the OpenFlights Airport to an in-memory table (once), and returns an entry that matches the passed UN/LOCODE record.
Records are matched if they have the same country code and either same IATA code or same city name (location name in UN/LOCODE).
Returns locodedb.ErrAirportNotFound if no entry matches.
type Prm ¶
type Prm struct { // Path to OpenFlights Airport csv table. // // Must not be empty. AirportsPath string // Path to OpenFlights Countries csv table. // // Must not be empty. CountriesPath string }
Prm groups the required parameters of the DB'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).