File tree Expand file tree Collapse file tree 18 files changed +65
-54
lines changed
Expand file tree Collapse file tree 18 files changed +65
-54
lines changed Original file line number Diff line number Diff line change 44
55require (
66 github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2
7+ github.com/clbanning/mxj v1.8.4
78 github.com/clbanning/x2j v0.0.0-20180326210544-5e605d46809c
89 github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
910 github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3
Original file line number Diff line number Diff line change 11github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 h1:axBiC50cNZOs7ygH5BgQp4N+aYrZ2DNpWZ1KG3VOSOM =
22github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 /go.mod h1:jnzFpU88PccN/tPPhCpnNU8mZphvKxYM9lLNkd8e+os =
3+ github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I =
4+ github.com/clbanning/mxj v1.8.4 /go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng =
35github.com/clbanning/x2j v0.0.0-20180326210544-5e605d46809c h1:gZ7YRTPnL5fRduIw4unEfQWLB/DInK29N2zYza16wfQ =
46github.com/clbanning/x2j v0.0.0-20180326210544-5e605d46809c /go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE =
57github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM =
Original file line number Diff line number Diff line change 1- package parse
1+ package parse_test
22
3- import "testing"
3+ import (
4+ "testing"
5+
6+ "github.com/stilvoid/please/parse"
7+ )
48
59const jsonInput = `{
610 "description": "some example json",
@@ -42,30 +46,30 @@ const queryInput = `an+array=0%3Dfirst%2Bentry%261%3Dnested%253Dobject%262%3D0%2
4246
4347func BenchmarkJSON (b * testing.B ) {
4448 for i := 0 ; i < b .N ; i ++ {
45- parseJSON ([]byte (jsonInput ))
49+ parse . Json ([]byte (jsonInput ))
4650 }
4751}
4852
4953func BenchmarkYAML (b * testing.B ) {
5054 for i := 0 ; i < b .N ; i ++ {
51- parseYAML ([]byte (yamlInput ))
55+ parse . Yaml ([]byte (yamlInput ))
5256 }
5357}
5458
5559func BenchmarkXML (b * testing.B ) {
5660 for i := 0 ; i < b .N ; i ++ {
57- parseXML ([]byte (xmlInput ))
61+ parse . Xml ([]byte (xmlInput ))
5862 }
5963}
6064
6165func BenchmarkQuery (b * testing.B ) {
6266 for i := 0 ; i < b .N ; i ++ {
63- parseQuery ([]byte (queryInput ))
67+ parse . Query ([]byte (queryInput ))
6468 }
6569}
6670
6771func BenchmarkHTML (b * testing.B ) {
6872 for i := 0 ; i < b .N ; i ++ {
69- parseHTML ([]byte (xmlInput ))
73+ parse . Html ([]byte (xmlInput ))
7074 }
7175}
Original file line number Diff line number Diff line change 55 "encoding/csv"
66)
77
8- func parseCSV (input []byte ) (interface {}, error ) {
8+ func Csv (input []byte ) (interface {}, error ) {
99 return csv .NewReader (bytes .NewReader (input )).ReadAll ()
1010}
Original file line number Diff line number Diff line change 1- package parse
1+ package parse_test
22
33import (
44 "reflect"
55 "testing"
6+
7+ "github.com/stilvoid/please/parse"
68)
79
810func TestCSV (t * testing.T ) {
@@ -11,12 +13,12 @@ func TestCSV(t *testing.T) {
1113 "2-1,2-2"
1214
1315 expected := [][]string {
14- [] string {"col1" , "col2" },
15- [] string {"1-1" , "1-2" },
16- [] string {"2-1" , "2-2" },
16+ {"col1" , "col2" },
17+ {"1-1" , "1-2" },
18+ {"2-1" , "2-2" },
1719 }
1820
19- actual , err := parseCSV ([]byte (input ))
21+ actual , err := parse . Csv ([]byte (input ))
2022
2123 if err != nil {
2224 t .Errorf ("unexpected error: %v" , err )
Original file line number Diff line number Diff line change @@ -9,13 +9,7 @@ import (
99 "golang.org/x/net/html"
1010)
1111
12- type node struct {
13- Node interface {} `xml:",any"`
14- List []interface {} `xml:",any"`
15- Value interface {} `xml:",any"`
16- }
17-
18- func parseHTML (input []byte ) (interface {}, error ) {
12+ func Html (input []byte ) (interface {}, error ) {
1913 var parsed interface {}
2014
2115 doc , err := html .Parse (bytes .NewReader (input ))
Original file line number Diff line number Diff line change 1- package parse
1+ package parse_test
22
33import (
44 "reflect"
55 "testing"
6+
7+ "github.com/stilvoid/please/parse"
68)
79
810func TestHTML (t * testing.T ) {
@@ -32,7 +34,7 @@ func TestHTML(t *testing.T) {
3234 },
3335 }
3436
35- actual , err := parseHTML ([]byte (input ))
37+ actual , err := parse . Html ([]byte (input ))
3638
3739 if err != nil {
3840 t .Errorf ("unexpected error: %v" , err )
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package parse
22
33import "encoding/json"
44
5- func parseJSON (input []byte ) (interface {}, error ) {
5+ func Json (input []byte ) (interface {}, error ) {
66 var parsed interface {}
77
88 err := json .Unmarshal (input , & parsed )
Original file line number Diff line number Diff line change 1- package parse
1+ package parse_test
22
33import (
44 "reflect"
55 "testing"
6+
7+ "github.com/stilvoid/please/parse"
68)
79
810func TestJSON (t * testing.T ) {
@@ -47,7 +49,7 @@ func TestJSON(t *testing.T) {
4749 input := inputs [i ]
4850 expected := expecteds [i ]
4951
50- actual , err := parseJSON ([]byte (input ))
52+ actual , err := parse . Json ([]byte (input ))
5153
5254 if err != nil {
5355 t .Errorf ("unexpected error: %v" , err )
Original file line number Diff line number Diff line change 77 "net/textproto"
88)
99
10- func parseMIME (input []byte ) (interface {}, error ) {
10+ func Mime (input []byte ) (interface {}, error ) {
1111 inputReader := bufio .NewReader (bytes .NewReader (input ))
1212
1313 reader := textproto .NewReader (inputReader )
You can’t perform that action at this time.
0 commit comments