Go Persian Tools

An anthology of tools for working with Persian (Iranian) data in Go — with no dependencies.

Go Reference CI Go Report Card License MIT

Packages

text

Normalize Persian text, fold Arabic look-alikes, recover text typed on the wrong keyboard layout, and romanize to Finglish.

digit

Convert between Persian, Arabic-Indic and ASCII digits, group and spell numbers, and format Toman and Rial.

bank

Validate card numbers (Luhn), resolve the issuing bank, and validate Sheba (IBAN) codes with bank details.

nationalid

Validate national numbers (code-e Melli) and resolve the issuing city and province.

phonenumbers

Validate Iranian mobile numbers, normalize prefixes and resolve operator details.

bill

Determine a utility bill's type, amount and barcode, and validate its id.

Install

# requires Go 1.22+ — the module has no dependencies
go get github.com/amiranmanesh/go-persian-tools@latest

Quick start

// text — normalize for comparison
import "github.com/amiranmanesh/go-persian-tools/text"

text.FixArabic("علي كريم")   // علی کریم
text.SwitchToPersianKey("sghl") // سلام
text.Finglish("سلام")        // salam
// digits, money and validators
import "github.com/amiranmanesh/go-persian-tools/digit"

digit.ToWords(156789)   // صد و پنجاه و شش هزار و ...
digit.Toman("1234567") // ۱،۲۳۴،۵۶۷ تومان
nationalid.Validate("0067749828") // true
bank.CardInfo("6037701689095443")  // keshavarzi

Command line

go install github.com/amiranmanesh/go-persian-tools/cmd/persian-tools@latest

persian-tools normalize "علي كريم"          # علی کریم
persian-tools words 156789                   # صد و پنجاه و شش هزار و ...
persian-tools currency -unit toman 1234567   # ۱،۲۳۴،۵۶۷ تومان
persian-tools national-id 0067749828         # true (exit 0; invalid exits 1)

cat names.txt | persian-tools normalize > keys.txt