JS>> ifc>> 返回
项目作者: whitone

项目描述 :
Go library to handle Italian fiscal code
高级语言: Go
项目地址: git://github.com/whitone/ifc.git
创建时间: 2020-06-08T18:44:36Z
项目社区:https://github.com/whitone/ifc

开源协议:BSD 3-Clause "New" or "Revised" License

下载


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.

  1. import "github.com/whitone/ifc"
  2. code, err := ifc.Encode("Doe", "John", 'M', "1999-12-13", "Malta")
  3. if err != nil {
  4. log.Fatal(err)
  5. }

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

  1. person, err := ifc.Decode("DOEJHN99T13Z121S")
  2. if err != nil {
  3. log.Fatal(err)
  4. }
  5. 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.

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

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.

  1. person := &ifc.Person{}
  2. err := person.CheckIfc("DOEJNA90H48G273P")
  3. if err != nil {
  4. log.Fatal(err)
  5. }
  6. 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.