馃嚙馃嚪 CPF validation in Go
Go 100.0%
19 1 2

Clone this repository

https://tangled.org/cuducos.me/go-cpf https://tangled.org/did:plc:3272gdrjsuikiff7qsgokgas/go-cpf
git@tangled.org:cuducos.me/go-cpf git@tangled.org:did:plc:3272gdrjsuikiff7qsgokgas/go-cpf

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

Go CPF GoDocGo version#

A Go module to validate CPF numbers (Brazilian unique identifier for the Federal Revenue).

package main

import "tangled.org/cuducos.me/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 鉂わ笍