github.com/elliotchance/gedcom (go): Copying  All nodes (since they implement the Node interface) also implement the NodeCopier interface which provides the ShallowCopy() function.  A shallow copy returns a new node with all the same properties, but no children.  On the other hand there is a DeepCopy function which returns a new node with all recursive children also copied. This ensures that the new returned node can be manipulated without affecting the original node or any of its children.  Dates in GEDCOM files can be very complex as they can cater for many scenarios:  1. Incomplete, like "Dec 1943"  2. Anchored, like "Aft. 3 Sep 2003" or "Before 1923"  3. Ranges, like "Bet. 4 Apr 1823 and 8 Apr 1823"  4. Phrases, like "(Foo Bar)"  This package provides a very rich API for dealing with all kind of dates in a meaningful and sensible way. Some notable features include:  1. All dates, even though that specify an specific day have a minimum and maximum value that are their true bounds. This is especially important for larger date ranges like the whole month of "Jun 1945".  2. Upper and lower bounds of dates can be converted to the native Go time.Time object.  3. There is a Years function that provides a convenient way to normalise a date range into a number for easier distance and comparison measurements.  4. Algorithms for calculating the similarity of dates on a configurable parabola.  Decoding a GEDCOM stream:  If you are reading from a file you can use NewDocumentFromGEDCOMFile:  Package gedcom contains functionality for encoding, decoding, traversing, manipulating and comparing of GEDCOM data.  You can download the latest binaries for macOS, Windows and Linux on the Releases page: https://github.com/elliotchance/gedcom/releases  This will not require you to install Go or any other dependencies.  If you wish to build it from source you must install the dependencies with:  On top of the raw document is a powerful API that takes care of the complex traversing of the Document. Here is a simple example:  Some of the nodes in a GEDCOM file have been replaced with more function rich types, such as names, dates, families and more.  Encoding a Document  If you need the GEDCOM data as a string you can simply using fmt.Stringer:  The Filter function recursively removes or manipulates nodes with a FilterFunction:  Some examples of Filter functions include BlacklistTagFilter, OfficialTagFilter, SimpleNameFilter and WhitelistTagFilter.  There are several functions available that handle different kinds of merging:  - MergeNodes(left, right Node) Node: returns a new node that merges children from both nodes.  - MergeNodeSlices(left, right Nodes, mergeFn MergeFunction) Nodes: merges two slices based on the mergeFn. This allows more advanced merging when dealing with slices of nodes.  - MergeDocuments(left, right *Document, mergeFn MergeFunction) *Document: creates a new document with their respective nodes merged. You can use IndividualBySurroundingSimilarityMergeFunction with this to merge individuals, rather than just appending them all.  The MergeFunction is a type that can be received in some of the merging functions. The closure determines if two nodes should be merged and what the result would be. Alternatively it can also describe when two nodes should not be merged.  You may certainly create your own MergeFunction, but there are some that are already included:  - IndividualBySurroundingSimilarityMergeFunction creates a MergeFunction that will merge individuals if their surrounding similarity is at least minimumSimilarity.  - EqualityMergeFunction is a MergeFunction that will return a merged node if the node are considered equal (with Equals).  Node.Equals performs a shallow comparison between two nodes. The implementation is different depending on the types of nodes being compared. You should see the specific documentation for the Node.  Equality is not to be confused with the Is function seen on some of the nodes, such as Date.Is. The Is function is used to compare exact raw values in nodes.  DeepEqual tests if left and right are recursively equal.  CompareNodes recursively compares two nodes. For example:  Produces a *NodeDiff than can be rendered with the String method:
Keywords: converts|decoder|gedcom|gedcom-encoder|gedcom-files|go|json