A go library to parse the Serbian JMBG (Jedinstveni Matični Broj Građana), or UMCN (Unique Master Citizen Number)
The number that the government of Serbia assigns to its citizens is not random and is made up of the following information:
- A person's date of birth
- Which region of the country they were born in
- The sex they were assigned at birth
- A single digit checksum for error detection
type (
JMBG struct {
Number string
Digits [13]uint
DateOfBirth time.Time
Region region.Region
Sex sex.Sex
Checksum checksum.Checksum
}
)
This library attempts to make it simple to extract this information out of a string representation of this number.
Make sure you have Go installed (download here).
Initialize your project in a directory of your choice and run go mod init github.com/your-username/your-repo-name
.
Then install the package with the go get
command:
go get -u github.com/dusnm/[email protected]
package main
import (
"fmt"
"log"
"github.com/dusnm/jmbg"
)
func main() {
number := "0101000805018"
data, err := jmbg.New(number)
if err != nil {
log.Fatal(err)
}
fmt.Println(data)
}
Licensed under the terms of the GNU Lesser General Public License, version 3