Documentation
¶
Overview ¶
Package international defines shared contracts for versioned international identifier datasets. Identifier-specific behavior lives in subpackages.
Example (SuccessorAdapters) ¶
package main
import (
"errors"
"fmt"
internationalpostgres "github.com/faustbrian/go-international/adapters/postgres"
internationalvalidation "github.com/faustbrian/go-international/adapters/validation"
internationalwire "github.com/faustbrian/go-international/adapters/wire"
"github.com/faustbrian/go-international/country"
validation "github.com/faustbrian/go-validation"
"github.com/faustbrian/go-wire"
"github.com/jackc/pgx/v5/pgtype"
)
func main() {
finland, _ := country.Parse("FI")
typeMap := pgtype.NewMap()
internationalpostgres.Register(typeMap)
dataType, _ := typeMap.TypeForValue(finland)
ctx, _ := validation.NewContext(validation.DefaultLimits())
report := internationalvalidation.Country().Validate(ctx, "FI")
_, unsupported := internationalwire.Encode(wire.FormatSOAP, finland)
fmt.Println(dataType.Name, report.Err(), errors.Is(unsupported, internationalwire.ErrUnsupportedFormat))
}
Output: text <nil> true
Index ¶
Examples ¶
Constants ¶
const MaxDatasetRecords = 100_000
MaxDatasetRecords bounds generic dataset comparison work.
Variables ¶
var ( // ErrInvalid identifies syntactically invalid input without retaining it. ErrInvalid = errors.New("international: invalid value") // ErrInvalidProvenance identifies incomplete or malformed source metadata. ErrInvalidProvenance = errors.New("international: invalid provenance") // ErrInvalidDataset identifies structurally invalid generated data. ErrInvalidDataset = errors.New("international: invalid dataset") // ErrResourceLimit identifies input rejected before excessive work. ErrResourceLimit = errors.New("international: resource limit exceeded") )
Functions ¶
func LowercaseUnicode ¶
LowercaseUnicode applies locale-neutral full Unicode lowercasing within a caller-owned byte budget. The transformation may expand text and therefore checks both input and output sizes. Each call owns its Caser, so callers may invoke the function concurrently without sharing state.
Types ¶
type DatasetDiff ¶
type DatasetDiff struct {
Added []string `json:"added"`
Removed []string `json:"removed"`
AliasesChanged []string `json:"aliases_changed"`
StatusChanged []string `json:"status_changed"`
MetadataChanged []string `json:"metadata_changed"`
}
DatasetDiff classifies changes that require compatibility review.
func DiffRecords ¶
func DiffRecords(before, after []Record) (DatasetDiff, error)
DiffRecords deterministically classifies changes between two projections.
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError is a bounded diagnostic that never stores or echoes caller input.
func NewParseError ¶
func NewParseError(kind, reason string) *ParseError
NewParseError creates a redacted parse error for a public value kind.
func (*ParseError) Error ¶
func (err *ParseError) Error() string
Error returns a bounded, input-redacted diagnostic.
func (*ParseError) Unwrap ¶
func (err *ParseError) Unwrap() error
Unwrap makes all ParseError values match ErrInvalid.
type Provenance ¶
type Provenance struct {
Dataset string `json:"dataset"`
Source string `json:"source"`
RetrievedAt time.Time `json:"retrieved_at"`
UpstreamVersion string `json:"upstream_version"`
License string `json:"license"`
SHA256 string `json:"sha256"`
Generator string `json:"generator"`
Transformations []string `json:"transformations"`
}
Provenance records enough information to reproduce and review a dataset.
func (Provenance) Equal ¶
func (provenance Provenance) Equal(other Provenance) bool
Equal reports whether all immutable provenance fields match.
func (Provenance) Validate ¶
func (provenance Provenance) Validate() error
Validate verifies required provenance fields without network access.
type Record ¶
type Record struct {
ID string `json:"id"`
Status Status `json:"status"`
Fingerprint string `json:"fingerprint"`
AliasOf string `json:"alias_of"`
}
Record is the compatibility-relevant projection of a generated entry.
type Status ¶
type Status uint8
Status describes the registry standing of an identifier. It is metadata, not a claim that an identifier is suitable for a particular business use.
const ( // StatusUnknown means no authoritative status is available. StatusUnknown Status = iota // StatusOfficial identifies a currently assigned standards entry. StatusOfficial // StatusReserved identifies an entry retained by its authority. StatusReserved // StatusTransitional identifies an entry in a defined transition period. StatusTransitional // StatusDeleted identifies an entry removed from current assignment. StatusDeleted // StatusUserAssigned identifies a standards-defined private-use entry. StatusUserAssigned // StatusHistoric identifies an entry available only through opt-in history. StatusHistoric )
func ParseStatus ¶
ParseStatus parses one stable wire spelling without aliases or casing repair.
func (Status) MarshalJSON ¶
MarshalJSON encodes the status as its stable string spelling.
func (Status) MarshalText ¶
MarshalText returns the stable status wire spelling.
func (*Status) UnmarshalJSON ¶
UnmarshalJSON accepts only a stable status string spelling.
func (*Status) UnmarshalText ¶
UnmarshalText parses one stable status wire spelling without changing the receiver on error.
Directories
¶
| Path | Synopsis |
|---|---|
|
adapters
|
|
|
postgres
Package internationalpostgres registers International scalar values with caller-owned pgx type maps without connection I/O or retained resources.
|
Package internationalpostgres registers International scalar values with caller-owned pgx type maps without connection I/O or retained resources. |
|
validation
Package internationalvalidation exposes pure synchronous Validation rules backed by International's strict, bounded parsers.
|
Package internationalvalidation exposes pure synchronous Validation rules backed by International's strict, bounded parsers. |
|
wire
Package internationalwire provides bounded strict wire dispatch for structures containing International scalar values.
|
Package internationalwire provides bounded strict wire dispatch for structures containing International scalar values. |
|
cmd
|
|
|
international-dataset-review
command
Command international-dataset-review snapshots and compares governed data.
|
Command international-dataset-review snapshots and compares governed data. |
|
international-generate
command
Command international-generate updates pinned international metadata.
|
Command international-generate updates pinned international metadata. |
|
Package country provides strict ISO 3166-1 identifiers and CLDR-backed display metadata.
|
Package country provides strict ISO 3166-1 identifiers and CLDR-backed display metadata. |
|
Package currency provides ISO 4217 identity and versioned metadata.
|
Package currency provides ISO 4217 identity and versioned metadata. |
|
internal
|
|
|
codec
Package codec centralizes strict scalar encoding behavior for identifier packages.
|
Package codec centralizes strict scalar encoding behavior for identifier packages. |
|
datasetreview
Package datasetreview creates bounded semantic snapshots of generated data.
|
Package datasetreview creates bounded semantic snapshots of generated data. |
|
generate
Package generate produces pinned international metadata tables.
|
Package generate produces pinned international metadata tables. |
|
wireadapter
Package wireadapter owns the shared bounded dispatch used by both public International wire paths.
|
Package wireadapter owns the shared bounded dispatch used by both public International wire paths. |
|
Package internationalpgx registers international value types with pgx without adding a pgx dependency to the core domain packages.
|
Package internationalpgx registers international value types with pgx without adding a pgx dependency to the core domain packages. |
|
Package internationaltest provides reusable authoritative fixture helpers and provenance assertions for downstream package tests.
|
Package internationaltest provides reusable authoritative fixture helpers and provenance assertions for downstream package tests. |
|
Package internationalvalidation integrates strict international parsers with validation without introducing validation dependencies into core types.
|
Package internationalvalidation integrates strict international parsers with validation without introducing validation dependencies into core types. |
|
Package internationalwire provides bounded wire dispatch for structures containing international scalar types.
|
Package internationalwire provides bounded wire dispatch for structures containing international scalar types. |
|
Package language provides strict ISO 639 identifiers backed by the IANA Language Subtag Registry through a pinned golang.org/x/text release.
|
Package language provides strict ISO 639 identifiers backed by the IANA Language Subtag Registry through a pinned golang.org/x/text release. |
|
Package locale provides bounded BCP 47 tags with explicit canonicalization and fallback policies.
|
Package locale provides bounded BCP 47 tags with explicit canonicalization and fallback policies. |
|
Package phone provides bounded, immutable libphonenumber-backed values.
|
Package phone provides bounded, immutable libphonenumber-backed values. |
|
Package postal provides bounded postal-code values with explicit country context.
|
Package postal provides bounded postal-code values with explicit country context. |
|
Package subdivision provides ISO 3166-2-style identifiers backed by pinned CLDR validity and English display metadata.
|
Package subdivision provides ISO 3166-2-style identifiers backed by pinned CLDR validity and English display metadata. |