Go library for validation and generation of Russian official document codes.
Note: The API is not yet stable and may change in future versions.
| Code | Description | Validate | Generate |
|---|---|---|---|
| BIK | Bank Identification Code (БИК) | + | + |
| INN | Taxpayer Identification Number (ИНН) | + | + |
| KPP | Tax Registration Reason Code (КПП) | + | + |
| OGRN | Primary State Registration Number (ОГРН) | + | + |
| OGRNIP | Primary State Registration Number for IE (ОГРНИП) | + | + |
| SNILS | Insurance Individual Account Number (СНИЛС) | + | + |
| OKATO | Russian Classification of Administrative Territories | - | - |
- Go 1.25+
go get github.com/sshaplygin/docs-codeimport (
"log"
docs_code "github.com/sshaplygin/docs-code"
)
isValid, err := docs_code.Validate(docs_code.INN, "526317984689")
if err != nil {
log.Fatal(err)
}
if !isValid {
log.Println("INN is invalid")
} else {
log.Println("INN is valid")
}import (
"fmt"
docs_code "github.com/sshaplygin/docs-code"
)
code := docs_code.Generate(docs_code.INN)
fmt.Println("Generated INN:", code)Each document type also exposes its own package with additional functions:
import "github.com/sshaplygin/docs-code/inn"
// Generate specific INN types
legalINN := inn.GenerateLegal()
physicalINN := inn.GeneratePhysical()
// Validate
ok, err := inn.Validate("526317984689")See BENCHMARKS.md for performance data.
docs-code/
├── bik/ # BIK validation and generation
├── inn/ # INN validation and generation
├── kpp/ # KPP validation and generation
├── ogrn/ # OGRN validation and generation
├── ogrnip/ # OGRNIP validation and generation
├── okato/ # OKATO (in progress)
├── snils/ # SNILS validation and generation
├── fts/ # Federal Tax Service data (regions, departments)
├── models/ # Shared error types
├── utils/ # Internal helpers
└── parser/ # Data parsers (BIK, OKATO, subjects)