Skip to content

Latest commit

 

History

History
80 lines (63 loc) · 2.48 KB

README.md

File metadata and controls

80 lines (63 loc) · 2.48 KB

godoc reference build status go report card total alerts license

ifc

The ifc package allows to handle Italian fiscal code.

Example

Just import the library to generate the Italian fiscal code from the data of a person.

import "github.com/whitone/ifc"

code, err := ifc.Encode("Doe", "John", 'M', "1999-12-13", "Malta")
if err != nil {
  log.Fatal(err)
}

The library also check if a code is valid and return all available informations of the person.

person, err := ifc.Decode("DOEJHN99T13Z121S")
if err != nil {
  log.Fatal(err)
}
log.Println("sex: %c, birthdate: %s, birthplace: %s", person.Sex, person.BirthDate, person.BirthPlace)

Another way to use the library is to set all required informations of person and then generate the code.

person := &ifc.Person{}
person.Surname = "Doe"
person.Name = "Jane"
person.Sex = 'F'
person.BirthDate = time.Now().AddDate(-30, 0, 0).Format("2006-01-02")
person.BirthPlace = "Palermo"
code, err := person.Ifc()
if err != nil {
  log.Fatal(err)
}

The opposite is to use the check method to fulfill the person with all its informations, be aware that any previous data will be overwritten.

person := &ifc.Person{}
err := person.CheckIfc("DOEJNA90H48G273P")
if err != nil {
  log.Fatal(err)
}
log.Println("sex: %c, birthdate: %s, birthplace: %s", person.Sex, person.BirthDate, person.BirthPlace)

Useful references

License

ifc is licensed under the BSD-3-Clause License.