🇧🇷 CPF and CNPJ validation in Go

Moves to Tangled

+31 -14
+16
.tangled/workflows/tests.yaml
··· 1 + when: 2 + - event: ["push"] 3 + branch: ["main"] 4 + engine: "nixery" 5 + dependencies: 6 + nixpkgs: 7 + - gcc 8 + - go 9 + - golangci-lint 10 + steps: 11 + - name: Formatting 12 + command: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi 13 + - name: Linter 14 + command: golangci-lint run ./... 15 + - name: Tests 16 + command: go test -v -race ./...
+5 -4
README.md
··· 1 - # Go CNPF [![Tests](https://github.com/cuducos/go-cnpf/workflows/Tests/badge.svg)]() [![GoDoc](https://godoc.org/github.com/cuducos/go-cnpf?status.svg)](https://godoc.org/github.com/cuducos/go-cnpf) ![Go version](https://img.shields.io/github/go-mod/go-version/cuducos/go-cnpj) 1 + # Go CNPF [![GoDoc](https://godoc.org/tangled.org/cuducos.me/go-cnpf?status.svg)](https://godoc.org/tangled.org/cuducos.me/go-cnpf) 2 2 3 3 A Go module to validate CPF and CNPJ numbers (Brazilian people and companies unique identifier for the Federal Revenue). 4 4 ··· 7 7 ```go 8 8 package main 9 9 10 - import "github.com/cuducos/go-cnpf" 10 + import "tangled.org/cuducos.me/go-cnpf" 11 11 12 12 13 13 func main() { ··· 39 39 cnpj.Mask("12ABC34501DE35") 40 40 } 41 41 ``` 42 + 42 43 > [!IMPORTANT] 43 - > Starting in July 2026 [the CNPJ number will be alphanumeric](https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico). This package **already supports the new format**. If you **do not** want to support the new format, tag this package to [`v0.0.1`](https://github.com/cuducos/go-cnpf/releases/tag/v0.0.1). 44 + > Starting in July 2026 [the CNPJ number will be alphanumeric](https://www.gov.br/receitafederal/pt-br/acesso-a-informacao/acoes-e-programas/programas-e-atividades/cnpj-alfanumerico). This package **already supports the new format**. If you **do not** want to support the new format, tag this package to `v0.0.1`. 44 45 45 - Based on [Go CPF](https://github.com/cuducos/go-cpf) and [Go CNPJ](https://github.com/cuducos/go-cnpj) ❤️ 46 + Based on [Go CPF](https://tangled.org/cuducos.me/go-cpf) and [Go CNPJ](https://tangled.org/cuducos.me/go-cnpj) ❤️
+2 -2
cnpf.go
··· 1 1 package cnpf 2 2 3 3 import ( 4 - cnpj "github.com/cuducos/go-cnpj" 5 - cpf "github.com/cuducos/go-cpf" 4 + cnpj "tangled.org/cuducos.me/go-cnpj" 5 + cpf "tangled.org/cuducos.me/go-cpf" 6 6 ) 7 7 8 8 // Unmask removes any non-alphanumeric character (like punctuation) from a CPF
+1 -1
cnpf_test.go
··· 57 57 // Output: false 58 58 } 59 59 60 - func ExampleIsValid_IncompleteNumber() { 60 + func ExampleIsValid_incompleteNumber() { 61 61 fmt.Println(IsValid("123")) 62 62 // Output: false 63 63 }
+3 -3
go.mod
··· 1 - module github.com/cuducos/go-cnpf 1 + module tangled.org/cuducos.me/go-cnpf 2 2 3 3 go 1.14 4 4 5 5 require ( 6 - github.com/cuducos/go-cnpj v0.1.2 7 - github.com/cuducos/go-cpf v0.0.1 6 + tangled.org/cuducos.me/go-cnpj v0.1.3 7 + tangled.org/cuducos.me/go-cpf v0.0.2 8 8 )
+4 -4
go.sum
··· 1 - github.com/cuducos/go-cnpj v0.1.2 h1:EKfO9AJPjxBh/Pc8S+SMSeXvQ7kLwhDoF6te4md58OA= 2 - github.com/cuducos/go-cnpj v0.1.2/go.mod h1:Oe0M530eHl9eXExbNWriqTD9kMv618ScjlGtEey/f4Y= 3 - github.com/cuducos/go-cpf v0.0.1 h1:LCyzmLSMKv49Qu+M3sozypOvT3WfZfj1/10fUUkdrdw= 4 - github.com/cuducos/go-cpf v0.0.1/go.mod h1:+K4ER/oqiFbNHrTgg4ZZsAGdkP5C6Cj2+Dwo4Lv9p+A= 1 + tangled.org/cuducos.me/go-cnpj v0.1.3 h1:ieJwlBYseCCdAayJDg48x/fheoY6MAhjtR7CGdLJC5I= 2 + tangled.org/cuducos.me/go-cnpj v0.1.3/go.mod h1:+Y0GuONyK7BoSLSPnTYwBDSJ9HmTxcaT0nglim4GLa8= 3 + tangled.org/cuducos.me/go-cpf v0.0.2 h1:g0R0tSmQ4M/KzE+YxwtXDnBncY5yXfNWNvoH/FD9ILQ= 4 + tangled.org/cuducos.me/go-cpf v0.0.2/go.mod h1:GKk4loT5PisNTHF0XxzrfvmIxZTn9gJB6GXk48zWvgM=