tech: adds/removes in vendor folder according to dep 0.4.0.
This commit is contained in:
-1
@@ -1 +0,0 @@
|
||||
*.test
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
test:
|
||||
if [ `go fmt $(go list ./... | grep -v /vendor/) | wc -l` -gt 0 ]; then echo "go fmt error"; exit 1; fi
|
||||
|
||||
tools:
|
||||
go get github.com/tools/godep
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
# Go JSON Diff (and Patch)
|
||||
|
||||
[][wercker]
|
||||
[][license]
|
||||
|
||||
[wercker]: https://app.wercker.com/project/bykey/00d70daaf40ce277fd4f10290f097b9d
|
||||
[license]: https://github.com/yudai/gojsondiff/blob/master/LICENS
|
||||
|
||||
## How to use
|
||||
|
||||
### Installation
|
||||
|
||||
```sh
|
||||
go get github.com/yudai/gojsondiff
|
||||
```
|
||||
|
||||
### Comparing two JSON strings
|
||||
|
||||
See `jd/main.go` for how to use this library.
|
||||
|
||||
|
||||
## CLI tool
|
||||
|
||||
This repository contains a package that you can use as a CLI tool.
|
||||
|
||||
### Instllation
|
||||
|
||||
```sh
|
||||
go get github.com/yudai/gojsondiff/jd
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
#### Diff
|
||||
|
||||
Just give two json files to the `jd` command:
|
||||
|
||||
```sh
|
||||
jd one.json another.json
|
||||
```
|
||||
|
||||
Outputs would be something like:
|
||||
|
||||
```diff
|
||||
{
|
||||
"arr": [
|
||||
0: "arr0",
|
||||
1: 21,
|
||||
2: {
|
||||
"num": 1,
|
||||
- "str": "pek3f"
|
||||
+ "str": "changed"
|
||||
},
|
||||
3: [
|
||||
0: 0,
|
||||
- 1: "1"
|
||||
+ 1: "changed"
|
||||
]
|
||||
],
|
||||
"bool": true,
|
||||
"num_float": 39.39,
|
||||
"num_int": 13,
|
||||
"obj": {
|
||||
"arr": [
|
||||
0: 17,
|
||||
1: "str",
|
||||
2: {
|
||||
- "str": "eafeb"
|
||||
+ "str": "changed"
|
||||
}
|
||||
],
|
||||
+ "new": "added",
|
||||
- "num": 19,
|
||||
"obj": {
|
||||
- "num": 14,
|
||||
+ "num": 9999
|
||||
- "str": "efj3"
|
||||
+ "str": "changed"
|
||||
},
|
||||
"str": "bcded"
|
||||
},
|
||||
"str": "abcde"
|
||||
}
|
||||
```
|
||||
|
||||
When you prefer the delta foramt of [jsondiffpatch](https://github.com/benjamine/jsondiffpatch), add the `-f delta` option.
|
||||
|
||||
```sh
|
||||
jd -f delta one.json another.json
|
||||
```
|
||||
|
||||
This command shows:
|
||||
|
||||
```json
|
||||
{
|
||||
"arr": {
|
||||
"2": {
|
||||
"str": [
|
||||
"pek3f",
|
||||
"changed"
|
||||
]
|
||||
},
|
||||
"3": {
|
||||
"1": [
|
||||
"1",
|
||||
"changed"
|
||||
],
|
||||
"_t": "a"
|
||||
},
|
||||
"_t": "a"
|
||||
},
|
||||
"obj": {
|
||||
"arr": {
|
||||
"2": {
|
||||
"str": [
|
||||
"eafeb",
|
||||
"changed"
|
||||
]
|
||||
},
|
||||
"_t": "a"
|
||||
},
|
||||
"new": [
|
||||
"added"
|
||||
],
|
||||
"num": [
|
||||
19,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"obj": {
|
||||
"num": [
|
||||
14,
|
||||
9999
|
||||
],
|
||||
"str": [
|
||||
"efj3",
|
||||
"changed"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Patch
|
||||
|
||||
Give a diff file in the delta format and the JSON file to the `jp` command.
|
||||
|
||||
```sh
|
||||
jp diff.delta one.json
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT License (see `LICENSE` for detail)
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
box: golang:1.6.3
|
||||
|
||||
build:
|
||||
steps:
|
||||
- setup-go-workspace
|
||||
- script:
|
||||
name: tools
|
||||
code: make tools
|
||||
- script:
|
||||
name: test
|
||||
code: make test
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
# Go Longest Common Subsequence (LCS)
|
||||
|
||||
[][godoc]
|
||||
[][license]
|
||||
|
||||
[godoc]: https://godoc.org/github.com/yudai/golcs
|
||||
[license]: https://github.com/yudai/golcs/blob/master/LICENSE
|
||||
|
||||
A package to calculate [LCS](http://en.wikipedia.org/wiki/Longest_common_subsequence_problem) of slices.
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
go get github.com/yudai/golcs
|
||||
```
|
||||
|
||||
```go
|
||||
import " github.com/yudai/golcs"
|
||||
|
||||
left = []interface{}{1, 2, 5, 3, 1, 1, 5, 8, 3}
|
||||
right = []interface{}{1, 2, 3, 3, 4, 4, 5, 1, 6}
|
||||
|
||||
lcs := golcs.New(left, right)
|
||||
|
||||
lcs.Values() // LCS values => []interface{}{1, 2, 5, 1}
|
||||
lcs.IndexPairs() // Matched indices => [{Left: 0, Right: 0}, {Left: 1, Right: 1}, {Left: 2, Right: 6}, {Left: 4, Right: 7}]
|
||||
lcs.Length() // Matched length => 4
|
||||
|
||||
lcs.Table() // Memo table
|
||||
```
|
||||
|
||||
All the methods of `Lcs` cache their return values. For example, the memo table is calculated only once and reused when `Values()`, `Length()` and other methods are called.
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### How can I give `[]byte` values to `Lcs()` as its arguments?
|
||||
|
||||
As `[]interface{}` is incompatible with `[]othertype` like `[]byte`, you need to create a `[]interface{}` slice and copy the values in your `[]byte` slice into it. Unfortunately, Go doesn't provide any mesure to cast a slice into `[]interface{}` with zero cost. Your copy costs O(n).
|
||||
|
||||
```go
|
||||
leftBytes := []byte("TGAGTA")
|
||||
left = make([]interface{}, len(leftBytes))
|
||||
for i, v := range leftBytes {
|
||||
left[i] = v
|
||||
}
|
||||
|
||||
rightBytes := []byte("GATA")
|
||||
right = make([]interface{}, len(rightBytes))
|
||||
for i, v := range rightBytes {
|
||||
right[i] = v
|
||||
}
|
||||
|
||||
lcs.New(left, right)
|
||||
```
|
||||
|
||||
|
||||
## LICENSE
|
||||
|
||||
The MIT license (See `LICENSE` for detail)
|
||||
Reference in New Issue
Block a user