A Go module to validate CPF numbers (Brazilian unique identifier for the Federal Revenue).
package main
import "github.com/cuducos/go-cpf"
func main() {
// these return true
cpf.IsValid("23858488135")
cpf.IsValid("238.584.881-35")
// these return false
cpf.IsValid("111.111.111-11")
cpf.IsValid("123.456.769/01")
cpf.IsValid("ABC.DEF.GHI-JK")
cpf.IsValid("123")
// this returns 11111111111
cpf.Unmask("111.111.111-11")
// this returns 111.111.111-11
cpf.Mask("11111111111")
}
I started to learn Go with Learn Go With Tests and this CPF (Brazilian unique identifier for the Federal Revenue) validation script is actually my very first lines in Go (except the ones from the book). I'm sharing it here to get feedback ❤️