Skip to content

Go package to handle Swedish social security numbers

License

Notifications You must be signed in to change notification settings

sieuwerts/swedish-ssn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swedish SSN

Build Status GoDoc

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.

Example

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)

About

Go package to handle Swedish social security numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%