Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEitherOnlyOneOption = errors.New("either of only one of Ignore() or Only() must be specified")
Functions ¶
func DiffFromFiles ¶ added in v0.1.0
DiffFromFiles calculates differences with flies' contents.
Example ¶
query, err := gojq.Parse(".d") if err != nil { panic(err) } from, err := os.Open("./testdata/from.json") if err != nil { panic(err) } to, err := os.Open("./testdata/to.json") if err != nil { panic(err) } diff, err := DiffFromFiles(from, to, Only(query)) if err != nil { panic(err) } fmt.Print(diff)
Output: --- from.json +++ to.json @@ -1,2 +1,2 @@ -4 +3
func DiffFromObjects ¶ added in v0.1.0
DiffFromObjects calculates differences with from and to.
Example (Ignore) ¶
query, err := gojq.Parse(".b, .c") if err != nil { panic(err) } diff, err := DiffFromObjects(lhs, rhs, Ignore(query)) if err != nil { panic(err) } fmt.Println(diff)
Output: --- from +++ to @@ -2,6 +2,6 @@ "a": 1, "b": null, "c": null, - "d": 4 + "d": 3 }
Example (Only) ¶
query, err := gojq.Parse(".d") if err != nil { panic(err) } diff, err := DiffFromObjects(lhs, rhs, Only(query)) if err != nil { panic(err) } fmt.Println(diff)
Output: --- from +++ to @@ -1,2 +1,2 @@ -4 +3
Types ¶
type Input ¶ added in v0.2.0
type Input struct { // Name is Input's name. // // It'll be used as patch's file name. Name string // X is an object decoded from JSON. X interface{} }
Input represents a pair of the object that decoded from JSON and its name.
Click to show internal directories.
Click to hide internal directories.