Documentation
¶
Overview ¶
Package gedcomgo provides a unified API for processing GEDCOM genealogical data files.
This package is the recommended entry point for most users. It provides simple, high-level functions for common operations while re-exporting the most frequently used types for single-import convenience.
Quick Start ¶
Parse a GEDCOM file:
file, _ := os.Open("family.ged")
doc, err := gedcomgo.Decode(file)
if err != nil {
log.Fatal(err)
}
for _, ind := range doc.Individuals() {
fmt.Println(ind.Names[0].Full)
}
Write a GEDCOM file:
file, _ := os.Create("output.ged")
err := gedcomgo.Encode(file, doc)
Validate a document:
errors := gedcomgo.Validate(doc)
for _, err := range errors {
fmt.Println(err)
}
Convert between versions:
converted, report, err := gedcomgo.Convert(doc, gedcomgo.Version70)
Power Users ¶
For advanced use cases requiring custom options, import the underlying packages directly:
- github.com/cacack/gedcom-go/decoder - Custom decode options, progress callbacks, diagnostics
- github.com/cacack/gedcom-go/encoder - Custom line endings, encoding options
- github.com/cacack/gedcom-go/validator - Configurable validation rules, quality reports
- github.com/cacack/gedcom-go/converter - Custom conversion options, strict mode
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
func Convert(doc *Document, targetVersion Version) (converted *Document, report *ConversionReport, err error)
Convert converts a GEDCOM document to the target version. It returns the converted document, a report detailing any transformations or data loss, and an error if conversion failed.
Supported conversions:
- 5.5 <-> 5.5.1 (minimal changes, mostly compatible)
- 5.5 <-> 7.0 (text handling, xref normalization)
- 5.5.1 <-> 7.0 (text handling, xref normalization)
For custom options (strict data loss mode, validation), use the converter package directly: converter.ConvertWithOptions().
func Encode ¶
Encode writes a GEDCOM document to a writer using default options. The output uses CRLF line endings as per the GEDCOM specification.
For custom options (line endings, encoding), use the encoder package directly: encoder.EncodeWithOptions().
func Validate ¶
Validate validates a GEDCOM document and returns any validation errors. This performs basic structural validation including cross-reference checks and required field validation.
For comprehensive validation with severity levels, use ValidateAll(). For custom validation configuration, use the validator package directly.
Types ¶
type ConversionReport ¶
type ConversionReport = gedcom.ConversionReport
ConversionReport contains the results of a GEDCOM version conversion.
type DecodeResult ¶
type DecodeResult = decoder.DecodeResult
DecodeResult contains the result of decoding a GEDCOM file with diagnostics. In lenient mode, Document may contain partial data even when diagnostics are present.
func DecodeWithDiagnostics ¶
func DecodeWithDiagnostics(r io.Reader) (*DecodeResult, error)
DecodeWithDiagnostics parses a GEDCOM file and returns both the document and any diagnostics. In lenient mode (the default), parse errors are collected as diagnostics rather than stopping parsing, allowing partial documents to be returned.
For custom options (strict mode, progress callbacks), use the decoder package directly: decoder.DecodeWithDiagnostics() with custom options.
type Document ¶
Document represents a complete GEDCOM file with all its records. Use Individuals(), Families(), Sources() to access typed collections.
type Individual ¶
type Individual = gedcom.Individual
Individual represents a person in the GEDCOM file.
type Issue ¶
Issue represents a validation finding with severity, context, and actionable information.
func ValidateAll ¶
ValidateAll returns comprehensive validation as Issues with severity levels. This is the enhanced API that provides more detail than Validate(), including date logic validation, reference checking, and quality analysis.
Issues are categorized by severity: Error, Warning, and Info. For custom validation configuration (strictness, thresholds), use the validator package directly: validator.NewWithConfig().
type Version ¶
Version represents a GEDCOM specification version.
const ( // Version55 represents GEDCOM 5.5 specification. Version55 Version = gedcom.Version55 // Version551 represents GEDCOM 5.5.1 specification. Version551 Version = gedcom.Version551 // Version70 represents GEDCOM 7.0 specification. Version70 Version = gedcom.Version70 )
Version constants for convenience.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package charset provides character encoding utilities for GEDCOM files.
|
Package charset provides character encoding utilities for GEDCOM files. |
|
Package converter provides GEDCOM version conversion functionality.
|
Package converter provides GEDCOM version conversion functionality. |
|
Package decoder provides high-level GEDCOM file decoding functionality.
|
Package decoder provides high-level GEDCOM file decoding functionality. |
|
Package encoder provides functionality to write GEDCOM documents to files.
|
Package encoder provides functionality to write GEDCOM documents to files. |
|
examples
|
|
|
date-parsing
command
Package main demonstrates parsing GEDCOM date values including modifiers, ranges, periods, and date comparison.
|
Package main demonstrates parsing GEDCOM date values including modifiers, ranges, periods, and date comparison. |
|
encode
command
Package main demonstrates creating GEDCOM documents programmatically and encoding them to standard GEDCOM format.
|
Package main demonstrates creating GEDCOM documents programmatically and encoding them to standard GEDCOM format. |
|
parse
command
Package main demonstrates basic GEDCOM file parsing with summary statistics, record counting, and validation.
|
Package main demonstrates basic GEDCOM file parsing with summary statistics, record counting, and validation. |
|
query
command
Package main demonstrates querying GEDCOM data including individual lookups, family traversal, and relationship navigation.
|
Package main demonstrates querying GEDCOM data including individual lookups, family traversal, and relationship navigation. |
|
validate
command
Package main demonstrates GEDCOM file validation with error categorization, grouping, and detailed reporting.
|
Package main demonstrates GEDCOM file validation with error categorization, grouping, and detailed reporting. |
|
Package gedcom defines the core data types for representing GEDCOM genealogy data.
|
Package gedcom defines the core data types for representing GEDCOM genealogy data. |
|
testing
Package testing provides round-trip test helpers for GEDCOM documents.
|
Package testing provides round-trip test helpers for GEDCOM documents. |
|
Package parser provides low-level GEDCOM line parsing functionality.
|
Package parser provides low-level GEDCOM line parsing functionality. |
|
Package validator provides GEDCOM document validation functionality.
|
Package validator provides GEDCOM document validation functionality. |
|
Package version provides GEDCOM version detection and validation.
|
Package version provides GEDCOM version detection and validation. |