This package aims to provide a toolset to handle Swedish social security numbers. A Swedish social security number uses the Luhn algorithm to calculate the checksum and create a valid number.
Validate social security number
reader := bufio.NewReader(os.Stdin)
fmt.Println("Enter social security number: ")
ssnInput, _ := reader.ReadString('\n')
ssn := swessn.New(ssnInput)
if ssn.Valid() {
fmt.Println("Valid SSN provided: %s", ssn)
}
minRequiredAge := 18
if ssn.IsOfAge(minRequiredAge) {
fmt.Println("Person is %d which is above %d", ssn.Age(), minRequiredAge)
}
Generate social security number
ssn1 := swessn.Generate(1990, 10, 10, "m")
ssn2 := swessn.Generate(1990, 10, 10, "f")
ssn3 := swessn.GenerateAny()
fmt.Printf("Male: %s, Female: %s, Random: %s\n", ssn1, ssn2, ssn3)