Documentation
¶
Overview ¶
Package vin decodes and validates a 17-character Vehicle Identification Number (ISO 3779 / ISO 3780). It is the offline complement to the automotive diagnostic stack: a VIN is what UDS ReadDataByIdentifier (DID 0xF190) and OBD-II Mode 09 PID 02 return, so an operator who has read one over CAN can validate and break it down here without any further bus access.
Wrap-vs-native judgement ¶
Native. The VIN structure, the position-9 check-digit algorithm (a fixed transliteration table + position weights, mod 11), the ISO 3780 first- character region ranges, and the 30-character model-year cycle are all public, fixed, deterministic specs — pure arithmetic and small fixed tables over a 17-byte string. There is nothing to wrap.
Verifiable / no confidently-wrong output ¶
The check digit is the verification anchor: it is recomputed from the other 16 characters and compared to position 9. Because the check digit is mandatory only in North America and China (other markets may carry any character there), a mismatch is reported as advisory — check_digit_valid plus a note — rather than asserting the VIN is invalid. The model-year code is genuinely ambiguous (the 30-character cycle repeats), so candidate years are returned, not a single confident year. The world-manufacturer identifier (WMI) is surfaced raw — the WMI-to-manufacturer registry is a large proprietary table, so a manufacturer name is deliberately NOT guessed.
Covered / deferred ¶
Covered: length + character-set validation (the I/O/Q exclusion), the check-digit computation + validity, the ISO 3780 region from the first character, the model-year candidates from position 10, and the structural split (WMI / VDS / VIS, plant code). Deferred: WMI-to-manufacturer lookup (proprietary), and any manufacturer-specific VDS interpretation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
VIN string `json:"vin"`
WMI string `json:"wmi"` // world manufacturer identifier (chars 1-3)
VDS string `json:"vds"` // vehicle descriptor section (chars 4-9)
VIS string `json:"vis"` // vehicle identifier section (chars 10-17)
Region string `json:"region"`
CheckDigit string `json:"check_digit"` // the character at position 9
CheckDigitComputed string `json:"check_digit_computed"` // recomputed from the other 16
CheckDigitValid bool `json:"check_digit_valid"`
ModelYearCode string `json:"model_year_code"` // character at position 10
ModelYearCandidates []int `json:"model_year_candidates"` // the cyclic-code candidate years
PlantCode string `json:"plant_code"` // character at position 11
SerialSection string `json:"serial_section"` // characters 12-17
Notes []string `json:"notes,omitempty"`
}
Result is the decoded view of a VIN.