Documentation
¶
Overview ¶
Package safediff computes the difference between two lists.
It is guaranteed to run in O(n), but may not produce an optimal diff. Most diffing algorithms produce optimal diffs but run in O(n²). It is safe to pass in untrusted input.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Lines ¶
Lines constructs a humanly readable line-by-line diff from x to y. The output (if multiple lines) is guaranteed to be no larger than maxSize, by truncating the output if necessary. A negative maxSize enforces no limit.
Example diff:
… 440 identical lines
"ssh": [
… 35 identical lines
{
- "src": ["[email protected]"],
- "dst": ["tag:maisem-test"],
- "users": ["maisem", "root"],
- "action": "check",
- // "recorder": ["100.12.34.56:80"],
+ "src": ["[email protected]"],
+ "dst": ["tag:maisem-test"],
+ "users": ["maisem", "root"],
+ "action": "check",
+ "recorder": ["node:recorder-2"],
},
… 77 identical lines
],
… 345 identical lines
Meaning of each line prefix:
- '…' precedes a summary statement
- ' ' precedes an identical line printed for context
- '-' precedes a line removed from x
- '+' precedes a line inserted from y
The diffing algorithm runs in O(n) and is safe to use with untrusted inputs.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.