Documentation ¶
Overview ¶
Package data is used to parse the insee number into a usable and human-readable data structure. All the required data is embedded in the package so no external file is required.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Male is one of the possible values for InseeData.Gender. Male = "homme" // Female is the other possible value for InseeData.Gender. Female = "femme" // Unknown is a value used when determining the value of a string field in InseeData was not possible. Unknown = "inconnu(e)" // France is the only item in the default slice for InseeData.Countries. France = "FRANCE" )
Functions ¶
This section is empty.
Types ¶
type InseeData ¶
type InseeData struct { // InseeNumber is the raw number, as given. InseeNumber string `json:"insee_number"` // Gender is either Male or Female. Gender string `json:"gender"` // Year of birth. Year int `json:"year"` // Month of birth. Month time.Month `json:"month"` // Department of birth, represented with its name. Department string `json:"department"` // City of birth, represented with its name. City string `json:"city"` // CityCode is the INSEE code of the City of birth. CityCode string `json:"city_code"` // Foreign is false if the person is born in France, true otherwise. Foreign bool `json:"foreign"` // Countries is the list of country names matching the CountryCode. // Some country codes may match multiple countries, so Countries is a slice. // This is always set to `{"FRANCE"}` when Foreign is false. Countries []string `json:"countries"` // CountryCode is the code of the birth country. CountryCode string `json:"country_code"` // Continent of birth. Continent string `json:"continent"` // OrderOfBirth is the order of birth of the person in the city or country (if Foreign) of birth at the year/month of birth. // For example, 384 would mean that the person is the 384th born in the specific city/country on the given year/month. OrderOfBirth int `json:"order_of_birth"` // ControlKey is the complement to 97 of the insee number (minus the last two digits) modulo 97. ControlKey int `json:"control_key"` }
InseeData contains human-readable data about the insee number used to construct it.
func NewInseeData ¶
NewInseeData generates an InseeData struct, extracting the data into the relevant fields. The data is converted to a human-readable format before being stored. If a value can't be determined, the corresponding field is generally set to Unknown. It returns an error when the given number isn't 15 characters long.
Click to show internal directories.
Click to hide internal directories.