From 87a230ea11bb9e048a3d613a9599c0da67736fba Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 19 Apr 2015 21:27:42 -0700 Subject: [PATCH 1/2] Update Godeps mxj and pb --- Godeps/Godeps.json | 4 +- .../cheggaaa/pb/example/copy/copy.go | 26 ++-- .../src/github.com/clbanning/mxj/anyxml.go | 11 +- .../github.com/clbanning/mxj/anyxml_test.go | 4 +- .../src/github.com/clbanning/mxj/data_test.go | 1 + .../src/github.com/clbanning/mxj/doc.go | 4 +- .../github.com/clbanning/mxj/example_test.go | 142 +++++++++--------- .../clbanning/mxj/examples/books.go | 2 +- .../clbanning/mxj/examples/getmetrics1.go | 4 +- .../clbanning/mxj/examples/getmetrics2.go | 4 +- .../clbanning/mxj/examples/getmetrics3.go | 2 +- .../clbanning/mxj/examples/getmetrics4.go | 8 +- .../clbanning/mxj/examples/gonuts1.go | 2 +- .../clbanning/mxj/examples/gonuts2.go | 24 +-- .../clbanning/mxj/examples/gonuts4.go | 2 +- .../clbanning/mxj/examples/gonuts6.go | 1 + .../src/github.com/clbanning/mxj/files.go | 12 +- .../github.com/clbanning/mxj/files_test.go | 6 +- .../src/github.com/clbanning/mxj/j2x/j2x.go | 1 + .../github.com/clbanning/mxj/j2x/j2x_test.go | 2 +- .../src/github.com/clbanning/mxj/j2x_test.go | 1 + .../src/github.com/clbanning/mxj/json.go | 2 +- .../src/github.com/clbanning/mxj/keyvalues.go | 2 +- .../clbanning/mxj/keyvalues_test.go | 6 +- .../src/github.com/clbanning/mxj/leafnode.go | 10 +- .../github.com/clbanning/mxj/leafnode_test.go | 1 + .../src/github.com/clbanning/mxj/mxj.go | 2 +- .../src/github.com/clbanning/mxj/mxj_test.go | 14 +- .../src/github.com/clbanning/mxj/newmap.go | 16 +- .../github.com/clbanning/mxj/newmap_test.go | 22 +-- .../github.com/clbanning/mxj/seqnum_test.go | 4 +- .../github.com/clbanning/mxj/struct_test.go | 43 +++--- .../github.com/clbanning/mxj/updatevalues.go | 2 +- .../clbanning/mxj/updatevalues_test.go | 55 +++---- .../src/github.com/clbanning/mxj/x2j/x2j.go | 2 +- .../src/github.com/clbanning/mxj/xml_test.go | 22 +-- 36 files changed, 241 insertions(+), 225 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 3ccc0351..f76df677 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -7,11 +7,11 @@ "Deps": [ { "ImportPath": "github.com/cheggaaa/pb", - "Rev": "c8232bc89810b5f103c82a07ea258040d3826c53" + "Rev": "0464652af750701d218b6dd035f0217e407caf2d" }, { "ImportPath": "github.com/clbanning/mxj", - "Rev": "62dd98ae54e1d2b67c9483486b1f45e344f8388c" + "Rev": "e11b85050263aff26728fb9863bf2ebaf6591279" }, { "ImportPath": "github.com/dustin/go-humanize", diff --git a/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go index 82b5329a..87738b2b 100644 --- a/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go +++ b/Godeps/_workspace/src/github.com/cheggaaa/pb/example/copy/copy.go @@ -1,14 +1,14 @@ package main import ( - "fmt" "github.com/cheggaaa/pb" - "io" - "net/http" "os" - "strconv" - "strings" + "fmt" + "io" "time" + "strings" + "net/http" + "strconv" ) func main() { @@ -18,12 +18,12 @@ func main() { return } sourceName, destName := os.Args[1], os.Args[2] - + // check source var source io.Reader var sourceSize int64 if strings.HasPrefix(sourceName, "http://") { - // open as url + // open as url resp, err := http.Get(sourceName) if err != nil { fmt.Printf("Can't get %s: %v\n", sourceName, err) @@ -54,7 +54,9 @@ func main() { sourceSize = sourceStat.Size() source = s } - + + + // create dest dest, err := os.Create(destName) if err != nil { @@ -62,15 +64,15 @@ func main() { return } defer dest.Close() - - // create bar + + // create bar bar := pb.New(int(sourceSize)).SetUnits(pb.U_BYTES).SetRefreshRate(time.Millisecond * 10) bar.ShowSpeed = true bar.Start() - + // create multi writer writer := io.MultiWriter(dest, bar) - + // and copy io.Copy(writer, source) bar.Finish() diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml.go b/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml.go index 5579e103..4eb6001d 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml.go @@ -9,21 +9,21 @@ const ( DefaultElementTag = "element" ) -// Encode arbitrary value as XML. -// +// Encode arbitrary value as XML. +// // Note: unmarshaling the resultant // XML may not return the original value, since tag labels may have been injected // to create the XML representation of the value. /* Encode an arbitrary JSON object. package main - + import ( "encoding/json" "fmt" "github/clbanning/mxj" ) - + func main() { jsondata := []byte(`[ { "somekey":"somevalue" }, @@ -42,7 +42,7 @@ const ( } fmt.Println(string(x)) } - + output: somevalue @@ -110,6 +110,7 @@ func AnyXml(v interface{}, tags ...string) ([]byte, error) { return b, err } + // Encode an arbitrary value as a pretty XML string. // Alternative values for DefaultRootTag and DefaultElementTag can be set as: // AnyXmlIndent( v, "", " ", myRootTag, myElementTag). diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml_test.go index df722828..f4c80a51 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/anyxml_test.go @@ -43,7 +43,7 @@ func TestAnyXml(t *testing.T) { } fmt.Println("[]->x:", string(x)) - a := []interface{}{"try", "this", 3.14159265, true} + a := []interface{}{ "try", "this", 3.14159265, true } x, err = AnyXml(a) if err != nil { t.Fatal(err) @@ -82,7 +82,7 @@ func TestAnyXmlIndent(t *testing.T) { } fmt.Println("[]->x:\n", string(x)) - a := []interface{}{"try", "this", 3.14159265, true} + a := []interface{}{ "try", "this", 3.14159265, true } x, err = AnyXmlIndent(a, "", " ") if err != nil { t.Fatal(err) diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/data_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/data_test.go index 357513f6..b3a4aaec 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/data_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/data_test.go @@ -36,3 +36,4 @@ var jsondata = []byte(` {"book":{"author":"John Hawkes","review":"A lyrical novel about the construction of Ft. Peck Dam in Montana.","title":"The Beetle Leg"}} {"book":{"author":{"first_name":"T.E.","last_name":"Porter"},"review":"A magical novella.","title":"King's Day"}} { "here":"we", "put":"in", "an":error }`) + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/doc.go b/Godeps/_workspace/src/github.com/clbanning/mxj/doc.go index 4db312c6..cb981310 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/doc.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/doc.go @@ -31,7 +31,7 @@ SUMMARY Marshal Map value, 'm', to an XML Writer (io.Writer): err := m.XmlWriter(xmlWriter) raw, err := m.XmlWriterRaw(xmlWriter) // 'raw' is the raw XML that was written on xmlWriter - + Also, for prettified output: xmlValue, err := m.XmlIndent(prefix, indent, ...) err := m.XmlIndentWriter(xmlWriter, prefix, indent, ...) @@ -72,7 +72,7 @@ XML PARSING CONVENTIONS - Attributes are parsed to map[string]interface{} values by prefixing a hyphen, '-', to the attribute label. (PrependAttrWithHyphen(false) will override this.) - If the element is a simple element and has attributes, the element value - is given the key '#text' for its map[string]interface{} representation. + is given the key '#text' for its map[string]interface{} representation. XML ENCODING CONVENTIONS diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/example_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/example_test.go index 81fb2861..5bcb0ab0 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/example_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/example_test.go @@ -8,8 +8,8 @@ package mxj_test import ( "bytes" "fmt" - "github.com/clbanning/mxj" "io" + "github.com/clbanning/mxj" ) func ExampleHandleXmlReader() { @@ -246,59 +246,59 @@ func ExampleMap_ValuesForKeyPath() { } func ExampleMap_UpdateValuesForPath() { - /* +/* + +var biblioDoc = []byte(` + + + William Gaddis + + + The Recognitions + 1955 + A novel that changed the face of American literature. + + + JR + 1975 + Winner of National Book Award for Fiction. + + + +`) - var biblioDoc = []byte(` - - - William Gaddis - - - The Recognitions - 1955 - A novel that changed the face of American literature. - - - JR - 1975 - Winner of National Book Award for Fiction. - - - - `) + ... + m, merr := mxj.NewMapXml(biblioDoc) + if merr != nil { + // handle error + } - ... - m, merr := mxj.NewMapXml(biblioDoc) - if merr != nil { - // handle error - } + // change 'review' for a book + count, err := m.UpdateValuesForPath("review:National Book Award winner." "*.*.*.*", "title:JR") + if err != nil { + // handle error + } + ... - // change 'review' for a book - count, err := m.UpdateValuesForPath("review:National Book Award winner." "*.*.*.*", "title:JR") - if err != nil { - // handle error - } - ... - - // change 'date' value from string type to float64 type - // Note: the following is equivalent to m, merr := NewMapXml(biblioDoc, mxj.Cast). - path := m.PathForKeyShortest("date") - v, err := m.ValuesForPath(path) - if err != nil { - // handle error - } - var total int - for _, vv := range v { - oldVal := "date:" + vv.(string) - newVal := "date:" + vv.(string) + ":num" - n, err := m.UpdateValuesForPath(newVal, path, oldVal) - if err != nil { - // handle error - } - total += n - } - ... - */ + // change 'date' value from string type to float64 type + // Note: the following is equivalent to m, merr := NewMapXml(biblioDoc, mxj.Cast). + path := m.PathForKeyShortest("date") + v, err := m.ValuesForPath(path) + if err != nil { + // handle error + } + var total int + for _, vv := range v { + oldVal := "date:" + vv.(string) + newVal := "date:" + vv.(string) + ":num" + n, err := m.UpdateValuesForPath(newVal, path, oldVal) + if err != nil { + // handle error + } + total += n + } + ... +*/ } func ExampleMap_Copy() { @@ -313,32 +313,34 @@ func ExampleMap_Copy() { private string } s := str{IntVal: 4, StrVal: "now's the time", FloatVal: 3.14159, BoolVal: true, private: "Skies are blue"} - m := make(map[string]interface{}, 0) + m := make(map[string]interface{},0) m["struct"] = interface{}(s) m["struct_ptr"] = interface{}(&s) m["misc"] = interface{}(`Now is the time`) + mv := mxj.Map(m) - cp, _ := mv.Copy() + cp,_ := mv.Copy() fmt.Printf("mv:%s\n", mv.StringIndent(2)) fmt.Printf("cp:%s\n", cp.StringIndent(2)) - // Output: - // mv: - // struct :[unknown] mxj_test.str{IntVal:4, StrVal:"now's the time", FloatVal:3.14159, BoolVal:true, private:"Skies are blue"} - // struct_ptr :[unknown] &mxj_test.str{IntVal:4, StrVal:"now's the time", FloatVal:3.14159, BoolVal:true, private:"Skies are blue"} - // misc :[string] Now is the time - // cp: - // misc :[string] Now is the time - // struct : - // int :[float64] 4.00e+00 - // str :[string] now's the time - // float :[float64] 3.14e+00 - // bool :[bool] true - // struct_ptr : - // int :[float64] 4.00e+00 - // str :[string] now's the time - // float :[float64] 3.14e+00 - // bool :[bool] true +// Output: +// mv: +// struct :[unknown] mxj_test.str{IntVal:4, StrVal:"now's the time", FloatVal:3.14159, BoolVal:true, private:"Skies are blue"} +// struct_ptr :[unknown] &mxj_test.str{IntVal:4, StrVal:"now's the time", FloatVal:3.14159, BoolVal:true, private:"Skies are blue"} +// misc :[string] Now is the time +// cp: +// misc :[string] Now is the time +// struct : +// int :[float64] 4.00e+00 +// str :[string] now's the time +// float :[float64] 3.14e+00 +// bool :[bool] true +// struct_ptr : +// int :[float64] 4.00e+00 +// str :[string] now's the time +// float :[float64] 3.14e+00 +// bool :[bool] true } + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/books.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/books.go index e703d839..8c43d05f 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/books.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/books.go @@ -4,8 +4,8 @@ package main import ( "fmt" - "github.com/clbanning/mxj" "log" + "github.com/clbanning/mxj" ) var xmldata = []byte(` diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics1.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics1.go index c4e68038..91c62461 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics1.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics1.go @@ -1,5 +1,5 @@ // getmetrics1.go - transform Eclipse Metrics (v3) XML report into CSV files for each metric -// Uses NewMapXmlReader on os.File without copying the raw XML into a buffer while decoding.. +// Uses NewMapXmlReader on os.File without copying the raw XML into a buffer while decoding.. // Shows no significant overhead for not first buffering large XML file as in getmetrics2.go. /* @@ -38,10 +38,10 @@ package main import ( "flag" "fmt" - "github.com/clbanning/mxj" "log" "os" "time" + "github.com/clbanning/mxj" ) func main() { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics2.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics2.go index 65d6c951..a11cbd75 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics2.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics2.go @@ -39,10 +39,10 @@ package main import ( "flag" "fmt" - "github.com/clbanning/mxj" "log" "os" "time" + "github.com/clbanning/mxj" ) func main() { @@ -81,7 +81,7 @@ func main() { fmt.Println(time.Now().String(), "... XML Unmarshaled - len:", len(m)) // Get just the key values of interest. - // Could also use m.ValuesForKey("Metric"), + // Could also use m.ValuesForKey("Metric"), // since there's just the one path. metricVals, err := m.ValuesForPath("Metrics.Metric") if err != nil { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics3.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics3.go index a914d549..370702fb 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics3.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics3.go @@ -40,10 +40,10 @@ package main import ( "flag" "fmt" - "github.com/clbanning/mxj" "log" "os" "time" + "github.com/clbanning/mxj" ) func main() { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics4.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics4.go index 2cf66381..a8db0b7b 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics4.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/getmetrics4.go @@ -1,7 +1,7 @@ // getmetrics2.go - transform Eclipse Metrics (v3) XML report into CSV files for each metric // Uses an in-memory buffer for the XML data and direct XML decoding of the buffer into a Map. // Then XML buffer is decoded into a Map while the raw XML is copied using NewMapXmlReaderRaw() -// to illustrate processing overhead relative to getmetrics2.go. Not a practical example, +// to illustrate processing overhead relative to getmetrics2.go. Not a practical example, // but confirms the getmetrics1.go vs. getmetrics3.go use case. /* @@ -41,10 +41,10 @@ import ( "bytes" "flag" "fmt" - "github.com/clbanning/mxj" "log" "os" "time" + "github.com/clbanning/mxj" ) func main() { @@ -79,7 +79,7 @@ func main() { // load XML into a Map value // Note: there is a single record with root tag of "Metrics". - m, raw, merr := mxj.NewMapXmlReaderRaw(xmlReader) // don't catch the pointer to raw XML + m, raw, merr := mxj.NewMapXmlReaderRaw(xmlReader) // don't catch the pointer to raw XML if merr != nil { log.Fatal("merr:", merr.Error()) } @@ -87,7 +87,7 @@ func main() { fmt.Println("raw XML buffer size (should be same as File size):", len(*raw)) // Get just the key values of interest. - // Could also use m.ValuesForKey("Metric"), + // Could also use m.ValuesForKey("Metric"), // since there's just the one path. metricVals, err := m.ValuesForPath("Metrics.Metric") if err != nil { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts1.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts1.go index a0c5d6fc..0564fbc8 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts1.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts1.go @@ -6,8 +6,8 @@ package main import ( "bytes" "fmt" - "github.com/clbanning/mxj" "io" + "github.com/clbanning/mxj" ) // Demo how to compensate for irregular tag labels in data. diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts2.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts2.go index 6bd0bab7..8cacafee 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts2.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts2.go @@ -108,9 +108,9 @@ func fullPath(xmldata [][]byte) { } func partPath1(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "Envelope.Body.*.*.ClaimStatusCodeRecord" values, err := m.ValueForPath(path) if err != nil { @@ -130,9 +130,9 @@ func partPath1(msg []byte) { } func partPath2(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "Envelope.Body.*.*.*" values, err := m.ValueForPath(path) if err != nil { @@ -152,9 +152,9 @@ func partPath2(msg []byte) { } func partPath3(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "*.*.*.*.*" values, err := m.ValueForPath(path) if err != nil { @@ -174,9 +174,9 @@ func partPath3(msg []byte) { } func partPath4(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "*.*.*.*.*.Description" values, err := m.ValueForPath(path) if err != nil { @@ -196,9 +196,9 @@ func partPath4(msg []byte) { } func partPath5(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "*.*.*.*.*.*" values, err := m.ValueForPath(path) if err != nil { @@ -218,9 +218,9 @@ func partPath5(msg []byte) { } func partPath6(msg []byte) { - fmt.Println("\nmsg:", string(msg)) + fmt.Println("\nmsg:",string(msg)) m, _ := mxj.NewMapXml(msg) - fmt.Println("m:", m.StringIndent()) + fmt.Println("m:",m.StringIndent()) path := "*.*.*.*.*.*.*" values, err := m.ValueForPath(path) if err != nil { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts4.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts4.go index 5ad4f9df..8dfc30fd 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts4.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts4.go @@ -45,6 +45,6 @@ func main() { } for _, v := range values { - fmt.Println("v:", v) + fmt.Println("v:",v) } } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts6.go b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts6.go index 56b3d29e..ee2b8980 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts6.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/examples/gonuts6.go @@ -41,3 +41,4 @@ func main() { } var s = []byte(`{ "DBInstances": [ { "PubliclyAccessible": true, "MasterUsername": "postgres", "LicenseModel": "postgresql-license", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-e72a4282" } ], "InstanceCreateTime": "2014-06-29T03:52:59.268Z", "OptionGroupMemberships": [ { "Status": "in-sync", "OptionGroupName": "default:postgres-9-3" } ], "PendingModifiedValues": {}, "Engine": "postgres", "MultiAZ": true, "LatestRestorableTime": "2014-06-29T12:00:34Z", "DBSecurityGroups": [ { "Status": "active", "DBSecurityGroupName": "production-dbsecuritygroup-q4f0ugxpjck8" } ], "DBParameterGroups": [ { "DBParameterGroupName": "default.postgres9.3", "ParameterApplyStatus": "in-sync" } ], "AutoMinorVersionUpgrade": true, "PreferredBackupWindow": "06:59-07:29", "DBSubnetGroup": { "Subnets": [ { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-34e5d01c", "SubnetAvailabilityZone": { "Name": "us-east-1b", "ProvisionedIopsCapable": false } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-50759d27", "SubnetAvailabilityZone": { "Name": "us-east-1c", "ProvisionedIopsCapable": false } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-450a1f03", "SubnetAvailabilityZone": { "Name": "us-east-1d", "ProvisionedIopsCapable": false } } ], "DBSubnetGroupName": "default", "VpcId": "vpc-acb86cc9", "DBSubnetGroupDescription": "default", "SubnetGroupStatus": "Complete" }, "SecondaryAvailabilityZone": "us-east-1b", "ReadReplicaDBInstanceIdentifiers": [], "AllocatedStorage": 15, "BackupRetentionPeriod": 1, "DBName": "deis", "PreferredMaintenanceWindow": "fri:05:52-fri:06:22", "Endpoint": { "Port": 5432, "Address": "production.cfk8mskkbkeu.us-east-1.rds.amazonaws.com" }, "DBInstanceStatus": "available", "EngineVersion": "9.3.3", "AvailabilityZone": "us-east-1c", "DBInstanceClass": "db.m1.small", "DBInstanceIdentifier": "production" } ] }`) + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/files.go b/Godeps/_workspace/src/github.com/clbanning/mxj/files.go index 58971187..34030267 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/files.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/files.go @@ -9,7 +9,7 @@ import ( type Maps []Map func NewMaps() Maps { - return make(Maps, 0) + return make(Maps,0) } type MapRaw struct { @@ -33,7 +33,7 @@ func NewMapsFromJsonFile(name string) (Maps, error) { } defer fh.Close() - am := make([]Map, 0) + am := make([]Map,0) for { m, raw, err := NewMapJsonReaderRaw(fh) if err != nil && err != io.EOF { @@ -65,7 +65,7 @@ func NewMapsFromJsonFileRaw(name string) ([]MapRaw, error) { } defer fh.Close() - am := make([]MapRaw, 0) + am := make([]MapRaw,0) for { mr := new(MapRaw) mr.M, mr.R, err = NewMapJsonReaderRaw(fh) @@ -104,7 +104,7 @@ func NewMapsFromXmlFile(name string) (Maps, error) { } defer fh.Close() - am := make([]Map, 0) + am := make([]Map,0) for { m, raw, err := NewMapXmlReaderRaw(fh) if err != nil && err != io.EOF { @@ -130,6 +130,7 @@ func NewMapsFromXmlFileRaw(name string) ([]MapRaw, error) { XmlWriterBufSize = x }() + fi, err := os.Stat(name) if err != nil { return nil, err @@ -144,7 +145,7 @@ func NewMapsFromXmlFileRaw(name string) ([]MapRaw, error) { } defer fh.Close() - am := make([]MapRaw, 0) + am := make([]MapRaw,0) for { mr := new(MapRaw) mr.M, mr.R, err = NewMapXmlReaderRaw(fh) @@ -297,3 +298,4 @@ func (mvs Maps) XmlFileIndent(file, prefix, indent string) error { fh.WriteString(s) return nil } + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/files_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/files_test.go index 52778aef..2850902f 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/files_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/files_test.go @@ -104,7 +104,7 @@ func TestNewXmFileRaw(t *testing.T) { func TestMaps(t *testing.T) { fmt.Println("TestMaps()") mvs := NewMaps() - for i := 0; i < 2; i++ { + for i := 0 ; i < 2 ; i++ { m, _ := NewMapJson([]byte(`{ "this":"is", "a":"test" }`)) mvs = append(mvs, m) } @@ -138,7 +138,7 @@ func TestJsonFile(t *testing.T) { } fmt.Println("files_test_dup.json written") - err = am.JsonFileIndent("files_test_indent.json", "", " ") + err = am.JsonFileIndent("files_test_indent.json","", " ") if err != nil { t.Fatal(err.Error()) } @@ -160,7 +160,7 @@ func TestXmlFile(t *testing.T) { } fmt.Println("files_test_dup.xml written") - err = am.XmlFileIndent("files_test_indent.xml", "", " ") + err = am.XmlFileIndent("files_test_indent.xml","", " ") if err != nil { t.Fatal(err.Error()) } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x.go b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x.go index 868c55a5..afb7109f 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x.go @@ -6,6 +6,7 @@ // Wrappers for end-to-end JSON to XML transformation and value manipulation. package j2x + import ( . "github.com/clbanning/mxj" "io" diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x_test.go index 4a25605c..098f4822 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x/j2x_test.go @@ -4,8 +4,8 @@ package j2x import ( "bytes" - "fmt" "io/ioutil" + "fmt" "testing" ) diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x_test.go index b88a64d5..4bbc7cb1 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/j2x_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/j2x_test.go @@ -27,3 +27,4 @@ func TestJ2X(t *testing.T) { fmt.Println("j2x, m :", m) fmt.Println("j2x, xml :", string(x)) } + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/json.go b/Godeps/_workspace/src/github.com/clbanning/mxj/json.go index 34c1c0b3..b7bf0330 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/json.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/json.go @@ -124,7 +124,7 @@ var JsonUseNumber bool func NewMapJson(jsonVal []byte) (Map, error) { // empty or nil begets empty if len(jsonVal) == 0 { - m := make(map[string]interface{}, 0) + m := make(map[string]interface{},0) return m, nil } // handle a goofy case ... diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues.go b/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues.go index 203e935c..4fc95185 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues.go @@ -550,7 +550,7 @@ func (mv Map) PathsForKey(key string) []string { // unpack map keys to return res := make([]string, len(breadbasket)) var i int - for k := range breadbasket { + for k, _ := range breadbasket { res[i] = k i++ } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues_test.go index ad42a77c..a43bcb80 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/keyvalues_test.go @@ -132,7 +132,7 @@ func TestValuesForKey(t *testing.T) { if sserr != nil { t.Fatal("sserr:", sserr.Error()) } - for _, v := range ss { // should be len(ss) == 0 + for _, v := range ss { // should be len(ss) == 0 fmt.Println("... ss.v:", v) } } @@ -189,7 +189,7 @@ func TestValuesForPath(t *testing.T) { } } -func TestValuesForNotKey(t *testing.T) { +func TestValuesForNotKey( t *testing.T) { fmt.Println("ValuesForNotKey ...") m, merr := NewMapXml(doc1) if merr != nil { @@ -209,7 +209,7 @@ func TestValuesForNotKey(t *testing.T) { if sserr != nil { t.Fatal("sserr:", sserr.Error()) } - for _, v := range ss { // expect len(ss) == 0 + for _, v := range ss { // expect len(ss) == 0 fmt.Println("... ss.v:", v) } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode.go b/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode.go index 99f27165..bbed685d 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode.go @@ -23,7 +23,7 @@ type LeafNode struct { // LeafNodes - returns an array of all LeafNode values for the Map. // The option no_attr argument suppresses attribute values (keys with prepended hyphen, '-') // as well as the "#text" key for the associated simple element value. -func (mv Map) LeafNodes(no_attr ...bool) []LeafNode { +func (mv Map)LeafNodes(no_attr ...bool) []LeafNode { var a bool if len(no_attr) == 1 { a = no_attr[0] @@ -64,8 +64,8 @@ func getLeafNodes(path, node string, mv interface{}, l *[]LeafNode, noattr bool) // LeafPaths - all paths that terminate in LeafNode values. func (mv Map) LeafPaths(no_attr ...bool) []string { ln := mv.LeafNodes() - ss := make([]string, len(ln)) - for i := 0; i < len(ln); i++ { + ss := make([]string,len(ln)) + for i := 0 ; i < len(ln); i++ { ss[i] = ln[i].Path } return ss @@ -74,8 +74,8 @@ func (mv Map) LeafPaths(no_attr ...bool) []string { // LeafValues - all terminal values in the Map. func (mv Map) LeafValues(no_attr ...bool) []interface{} { ln := mv.LeafNodes() - vv := make([]interface{}, len(ln)) - for i := 0; i < len(ln); i++ { + vv := make([]interface{},len(ln)) + for i := 0 ; i < len(ln); i++ { vv[i] = ln[i].Value } return vv diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode_test.go index 9cb9dd71..7bf59b78 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/leafnode_test.go @@ -72,6 +72,7 @@ func TestLeafNodes(t *testing.T) { fmt.Printf("%#v\n", v) } + xmldata2 := []byte(` Item 2 is blue diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/mxj.go b/Godeps/_workspace/src/github.com/clbanning/mxj/mxj.go index 8e90c32b..01a6754e 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/mxj.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/mxj.go @@ -38,7 +38,7 @@ func (mv Map) Old() map[string]interface{} { // be represented as a map[string]interface{} value. func (mv Map) Copy() (Map, error) { // this is the poor-man's deep copy - // not efficient, but it works + // not efficient, but it works j, jerr := mv.Json() // must handle, we don't know how mv got built if jerr != nil { diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/mxj_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/mxj_test.go index 319e09e5..a0295b5e 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/mxj_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/mxj_test.go @@ -13,8 +13,8 @@ func TestMap(t *testing.T) { m := New() m["key"] = interface{}("value") - v := map[string]interface{}{"bool": true, "float": 3.14159, "string": "Now is the time"} - vv := []interface{}{3.1415962535, false, "for all good men"} + v := map[string]interface{}{ "bool":true, "float":3.14159, "string":"Now is the time" } + vv := []interface{}{ 3.1415962535, false, "for all good men" } v["listkey"] = interface{}(vv) m["newkey"] = interface{}(v) @@ -23,14 +23,14 @@ func TestMap(t *testing.T) { o := interface{}(m.Old()) switch o.(type) { - case map[string]interface{}: - // do nothing - default: - t.Fatal("invalid type for m.Old()") + case map[string]interface{}: + // do nothing + default: + t.Fatal("invalid type for m.Old()") } m, _ = NewMapXml([]byte(`HelloWorld`)) - fmt.Println("TestMap, m_fromXML:", m) + fmt.Println("TestMap, m_fromXML:",m) fmt.Println("TestMap, StringIndent:", m.StringIndent()) mm, _ := m.Copy() diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/newmap.go b/Godeps/_workspace/src/github.com/clbanning/mxj/newmap.go index fc1320c0..e9c7f0cf 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/newmap.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/newmap.go @@ -22,9 +22,9 @@ import ( "strings" ) -// (Map)NewMap - create a new Map from data in the current Map. +// (Map)NewMap - create a new Map from data in the current Map. // 'keypairs' are key mappings "oldKey:newKey" and specify that the current value of 'oldKey' -// should be the value for 'newKey' in the returned Map. +// should be the value for 'newKey' in the returned Map. // - 'oldKey' supports dot-notation as described for (Map)ValuesForPath() // - 'newKey' supports dot-notation but with no wildcards, '*', or indexed arrays // - "oldKey" is shorthand for for the keypair value "oldKey:oldKey" @@ -32,7 +32,7 @@ import ( // - if 'oldKey' does not exist in the current Map, it is not written to the new Map. // "null" is not supported unless it is the current Map. // - see newmap_test.go for several syntax examples -// +// // NOTE: mv.NewMap() == mxj.New(). func (mv Map) NewMap(keypairs ...string) (Map, error) { n := make(map[string]interface{}, 0) @@ -67,7 +67,7 @@ func (mv Map) NewMap(keypairs ...string) (Map, error) { return n, errors.New("newKey value cannot contain indexed arrays - " + v) } if oldKey == "" || newKey == "" { - return n, errors.New("oldKey or newKey is not specified - " + v) + return n, errors.New("oldKey or newKey is not specified - " + v) } // get oldKey value @@ -125,7 +125,7 @@ func addNewVal(n *map[string]interface{}, path []string, val []interface{}) { // The placement of the next value in the array is dependent // on the sequence of members - could land on a map or a nil // value first. TODO: how to test this. - a := make([]interface{}, 0) + a := make([]interface{},0) var foundmap bool for _, vv := range m[k].([]interface{}) { switch vv.(type) { @@ -135,7 +135,7 @@ func addNewVal(n *map[string]interface{}, path []string, val []interface{}) { continue } nm = make(map[string]interface{}, 0) - a = append(a, interface{}(nm)) + a = append(a,interface{}(nm)) foundmap = true case map[string]interface{}: if foundmap { // use the first one in array @@ -151,7 +151,7 @@ func addNewVal(n *map[string]interface{}, path []string, val []interface{}) { } // no map found in array if !foundmap { - nm = make(map[string]interface{}, 0) + nm = make(map[string]interface{},0) a = append(a, interface{}(nm)) } m[k] = interface{}(a) // must insert in map @@ -178,6 +178,6 @@ func addNewVal(n *map[string]interface{}, path []string, val []interface{}) { default: // v exists:string, float64, bool, map[string]interface, etc. a := make([]interface{}, 0) a = append(a, v, newVal) - m[k] = interface{}(a) + m[k] =interface{}(a) } } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/newmap_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/newmap_test.go index 7e3fdfea..0b250461 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/newmap_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/newmap_test.go @@ -1,9 +1,9 @@ package mxj import ( + "io" "bytes" "fmt" - "io" "testing" ) @@ -18,7 +18,7 @@ func TestNewMap(t *testing.T) { m, _ := NewMapJson(j) fmt.Printf("m: %#v\n", m) - fmt.Println("\n", `eval - m.NewMap("A:AA", "B:BB", "C:cc", "D:help")`) + fmt.Println("\n",`eval - m.NewMap("A:AA", "B:BB", "C:cc", "D:help")`) n, err := m.NewMap("A:AA", "B:BB", "C:cc", "D:help") if err != nil { fmt.Println("err:", err.Error()) @@ -26,11 +26,11 @@ func TestNewMap(t *testing.T) { j, _ = n.Json() fmt.Println("n.Json():", string(j)) x, _ := n.Xml() - fmt.Println("n.Xml():\n", string(x)) + fmt.Println("n.Xml():\n",string(x)) x, _ = n.XmlIndent("", " ") - fmt.Println("n.XmlIndent():\n", string(x)) + fmt.Println("n.XmlIndent():\n",string(x)) - fmt.Println("\n", `eval - m.NewMap("A:AA.A", "B:AA.B", "C:AA.B.cc", "D:hello.help")`) + fmt.Println("\n",`eval - m.NewMap("A:AA.A", "B:AA.B", "C:AA.B.cc", "D:hello.help")`) n, err = m.NewMap("A:AA.A", "B:AA.B", "C:AA.B.cc", "D:hello.help") if err != nil { fmt.Println("err:", err.Error()) @@ -38,12 +38,12 @@ func TestNewMap(t *testing.T) { j, _ = n.Json() fmt.Println("n.Json():", string(j)) x, _ = n.Xml() - fmt.Println("n.Xml():\n", string(x)) + fmt.Println("n.Xml():\n",string(x)) x, _ = n.XmlIndent("", " ") - fmt.Println("n.XmlIndent():\n", string(x)) + fmt.Println("n.XmlIndent():\n",string(x)) - var keypairs = []string{"A:xml.AA", "B:xml.AA.hello.again", "C:xml.AA", "D:xml.AA.hello.help"} - fmt.Println("\n", `eval - m.NewMap keypairs:`, keypairs) + var keypairs = []string{ "A:xml.AA", "B:xml.AA.hello.again", "C:xml.AA", "D:xml.AA.hello.help" } + fmt.Println("\n",`eval - m.NewMap keypairs:`,keypairs) n, err = m.NewMap(keypairs...) if err != nil { fmt.Println("err:", err.Error()) @@ -51,9 +51,9 @@ func TestNewMap(t *testing.T) { j, _ = n.Json() fmt.Println("n.Json():", string(j)) x, _ = n.Xml() - fmt.Println("n.Xml():\n", string(x)) + fmt.Println("n.Xml():\n",string(x)) x, _ = n.XmlIndent("", " ") - fmt.Println("n.XmlIndent():\n", string(x)) + fmt.Println("n.XmlIndent():\n",string(x)) } // Need to normalize from an XML stream the values for "netid" and "idnet". diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/seqnum_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/seqnum_test.go index 7b48a7ca..208eb27f 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/seqnum_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/seqnum_test.go @@ -30,7 +30,7 @@ func TestSeqNumHeader(t *testing.T) { } func TestSeqNum(t *testing.T) { - IncludeTagSeqNum(true) + IncludeTagSeqNum( true ) m, err := NewMapXml(seqdata1, Cast) if err != nil { @@ -48,5 +48,5 @@ func TestSeqNum(t *testing.T) { j, _ = m.JsonIndent("", " ") fmt.Println(string(j)) - IncludeTagSeqNum(false) + IncludeTagSeqNum( false ) } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/struct_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/struct_test.go index 799de778..91af0f6e 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/struct_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/struct_test.go @@ -11,29 +11,29 @@ func TestStructHeader(t *testing.T) { func TestNewMapStruct(t *testing.T) { type str struct { - IntVal int `json:"int"` - StrVal string `json:"str"` + IntVal int `json:"int"` + StrVal string `json:"str"` FloatVal float64 `json:"float"` - BoolVal bool `json:"bool"` - private string + BoolVal bool `json:"bool"` + private string } - s := str{IntVal: 4, StrVal: "now's the time", FloatVal: 3.14159, BoolVal: true, private: "It's my party"} + s := str{ IntVal:4, StrVal:"now's the time", FloatVal:3.14159, BoolVal:true, private:"It's my party" } m, merr := NewMapStruct(s) if merr != nil { t.Fatal("merr:", merr.Error()) } - fmt.Printf("NewMapStruct, s: %#v\n", s) - fmt.Printf("NewMapStruct, m: %#v\n", m) + fmt.Printf("NewMapStruct, s: %#v\n",s) + fmt.Printf("NewMapStruct, m: %#v\n",m) m, merr = NewMapStruct(s) if merr != nil { t.Fatal("merr:", merr.Error()) } - fmt.Printf("NewMapStruct, s: %#v\n", s) - fmt.Printf("NewMapStruct, m: %#v\n", m) + fmt.Printf("NewMapStruct, s: %#v\n",s) + fmt.Printf("NewMapStruct, m: %#v\n",m) } func TestNewMapStructError(t *testing.T) { @@ -43,38 +43,38 @@ func TestNewMapStructError(t *testing.T) { t.Fatal("NewMapStructError, merr is nil") } - fmt.Println("NewMapStructError, merr:", merr.Error()) + fmt.Println("NewMapStructError, merr:",merr.Error()) } func TestStruct(t *testing.T) { type str struct { - IntVal int `json:"int"` - StrVal string `json:"str"` + IntVal int `json:"int"` + StrVal string `json:"str"` FloatVal float64 `json:"float"` - BoolVal bool `json:"bool"` - private string + BoolVal bool `json:"bool"` + private string } var s str - m := Map{"int": 4, "str": "now's the time", "float": 3.14159, "bool": true, "private": "Somewhere over the rainbow"} + m := Map{ "int":4, "str":"now's the time", "float":3.14159, "bool":true, "private":"Somewhere over the rainbow" } mverr := m.Struct(&s) if mverr != nil { t.Fatal("mverr:", mverr.Error()) } - fmt.Printf("Struct, m: %#v\n", m) - fmt.Printf("Struct, s: %#v\n", s) + fmt.Printf("Struct, m: %#v\n",m) + fmt.Printf("Struct, s: %#v\n",s) } func TestStructError(t *testing.T) { type str struct { - IntVal int `json:"int"` - StrVal string `json:"str"` + IntVal int `json:"int"` + StrVal string `json:"str"` FloatVal float64 `json:"float"` - BoolVal bool `json:"bool"` + BoolVal bool `json:"bool"` } var s str - mv := Map{"int": 4, "str": "now's the time", "float": 3.14159, "bool": true} + mv := Map{ "int":4, "str":"now's the time", "float":3.14159, "bool":true } mverr := mv.Struct(s) if mverr == nil { @@ -82,3 +82,4 @@ func TestStructError(t *testing.T) { } fmt.Println("StructError, mverr:", mverr.Error()) } + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues.go b/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues.go index fed54bc4..72413d2d 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues.go @@ -146,7 +146,7 @@ func updateValue(key string, value interface{}, m interface{}, keys0 string, sub switch m.(type) { case map[string]interface{}: // gotta have the last key if keys0 == "*" { - for k := range m.(map[string]interface{}) { + for k, _ := range m.(map[string]interface{}) { updateValue(key, value, m, k, subkeys, cnt) } return diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues_test.go index dca2da91..53f08471 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/updatevalues_test.go @@ -11,6 +11,7 @@ func TestUVHeader(t *testing.T) { fmt.Println("\n---------------- updatevalues_test.go ...\n") } + func TestUpdateValuesForPath_Author(t *testing.T) { m, merr := NewMapXml(doc1) if merr != nil { @@ -70,7 +71,7 @@ func TestUpdateValuesForPath_Author(t *testing.T) { fmt.Println("m:", m) fmt.Println("m.UpdateValuesForPath(mm, \"*\")") - mm, _ := NewMapXml(doc1) + mm, _ := NewMapXml(doc1) n, err = m.UpdateValuesForPath(mm, "*") if err != nil { t.Fatal("err:", err.Error()) @@ -82,7 +83,7 @@ func TestUpdateValuesForPath_Author(t *testing.T) { var newDoc = []byte(`simple element`) m, merr = NewMapXml(newDoc) if merr != nil { - t.Fatal("merr:", merr.Error()) + t.Fatal("merr:",merr.Error()) } fmt.Println("\nnewDoc:", string(newDoc)) fmt.Println("m:", m) @@ -93,29 +94,29 @@ func TestUpdateValuesForPath_Author(t *testing.T) { n, _ = m.UpdateValuesForPath("#text:simple element again", "*") fmt.Println("n:", n, "m:", m) - /* - fmt.Println("UpdateValuesForPath, doc.books.book, title:The Recognitions : NoBook") - n, err = m.UpdateValuesForPath("NoBook", "doc.books.book", "title:The Recognitions") - if err != nil { - t.Fatal("err:", err.Error()) - } - fmt.Println(n, "updates") - ss, _ = m.ValuesForPath("doc.books.book") - for _, v := range ss { - fmt.Println("v:", v) - } +/* + fmt.Println("UpdateValuesForPath, doc.books.book, title:The Recognitions : NoBook") + n, err = m.UpdateValuesForPath("NoBook", "doc.books.book", "title:The Recognitions") + if err != nil { + t.Fatal("err:", err.Error()) + } + fmt.Println(n, "updates") + ss, _ = m.ValuesForPath("doc.books.book") + for _, v := range ss { + fmt.Println("v:", v) + } - fmt.Println("UpdateValuesForPath, doc.books.book.title -seq=3: The Blood Oranges") - n, err = m.UpdateValuesForPath("The Blood Oranges", "doc.books.book.title", "-seq:3") - if err != nil { - t.Fatal("err:", err.Error()) - } - fmt.Println(n, "updates") - ss, _ = m.ValuesForPath("doc.books.book.title") - for _, v := range ss { - fmt.Println("v:", v) - } - */ + fmt.Println("UpdateValuesForPath, doc.books.book.title -seq=3: The Blood Oranges") + n, err = m.UpdateValuesForPath("The Blood Oranges", "doc.books.book.title", "-seq:3") + if err != nil { + t.Fatal("err:", err.Error()) + } + fmt.Println(n, "updates") + ss, _ = m.ValuesForPath("doc.books.book.title") + for _, v := range ss { + fmt.Println("v:", v) + } +*/ } var authorDoc = []byte(` @@ -159,7 +160,7 @@ var authorDoc = []byte(` func TestAuthorDoc(t *testing.T) { m, merr := NewMapXml(authorDoc) - if merr != nil { + if merr != nil { t.Fatal("merr:", merr.Error()) } fmt.Println(m.StringIndent()) @@ -174,7 +175,7 @@ func TestAuthorDoc(t *testing.T) { fmt.Println("m.UpdateValuesForPath(newVal, path, oldVal)") path := m.PathForKeyShortest("date") - v, _ := m.ValuesForPath(path) + v,_ := m.ValuesForPath(path) var counter int for _, vv := range v { oldVal := "date:" + vv.(string) @@ -185,3 +186,5 @@ func TestAuthorDoc(t *testing.T) { fmt.Println(counter, "updates") fmt.Println(m.StringIndent()) } + + diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/x2j/x2j.go b/Godeps/_workspace/src/github.com/clbanning/mxj/x2j/x2j.go index 5891aa1d..dad3f0aa 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/x2j/x2j.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/x2j/x2j.go @@ -38,7 +38,7 @@ func XmlToJson(xmlVal []byte, safeEncoding ...bool) ([]byte, error) { func XmlToJsonWriter(xmlVal []byte, jsonWriter io.Writer, safeEncoding ...bool) ([]byte, error) { m, err := NewMapXml(xmlVal) if err != nil { - return nil, err + return nil, err } return m.JsonWriterRaw(jsonWriter, safeEncoding...) } diff --git a/Godeps/_workspace/src/github.com/clbanning/mxj/xml_test.go b/Godeps/_workspace/src/github.com/clbanning/mxj/xml_test.go index 955923df..fc60d651 100644 --- a/Godeps/_workspace/src/github.com/clbanning/mxj/xml_test.go +++ b/Godeps/_workspace/src/github.com/clbanning/mxj/xml_test.go @@ -79,7 +79,7 @@ func TestNewMapXmlReader(t *testing.T) { // --------------------- Xml() and XmlWriter() test cases ------------------- func TestXml_1(t *testing.T) { - mv := Map{"tag1": "some data", "tag2": "more data", "boolean": true, "float": 3.14159625, "null": nil} + mv := Map{"tag1": "some data", "tag2": "more data", "boolean": true, "float": 3.14159625, "null":nil} x, err := mv.Xml() if err != nil { @@ -91,8 +91,8 @@ func TestXml_1(t *testing.T) { } func TestXml_2(t *testing.T) { - a := []interface{}{"string", true, 36.4} - mv := Map{"array": a} + a := []interface{}{ "string", true, 36.4 } + mv := Map{"array": a } x, err := mv.Xml() if err != nil { @@ -104,8 +104,8 @@ func TestXml_2(t *testing.T) { } func TestXml_3(t *testing.T) { - a := []interface{}{"string", true, 36.4} - mv := Map{"array": []interface{}{a, "string2"}} + a := []interface{}{ "string", true, 36.4 } + mv := Map{"array": []interface{}{a, "string2"} } x, err := mv.Xml() if err != nil { @@ -117,8 +117,8 @@ func TestXml_3(t *testing.T) { } func TestXml_4(t *testing.T) { - a := []interface{}{"string", true, 36.4} - mv := Map{"array": map[string]interface{}{"innerkey": []interface{}{a, "string2"}}} + a := []interface{}{ "string", true, 36.4 } + mv := Map{"array": map[string]interface{}{ "innerkey": []interface{}{a, "string2"} } } x, err := mv.Xml() if err != nil { @@ -130,8 +130,8 @@ func TestXml_4(t *testing.T) { } func TestXml_5(t *testing.T) { - a := []interface{}{"string", true, 36.4} - mv := Map{"array": []interface{}{map[string]interface{}{"innerkey": []interface{}{a, "string2"}}, map[string]interface{}{"some": "more"}}} + a := []interface{}{ "string", true, 36.4 } + mv := Map{"array": []interface{}{ map[string]interface{}{ "innerkey": []interface{}{a, "string2"} }, map[string]interface{}{"some":"more"} } } x, err := mv.Xml() if err != nil { @@ -148,10 +148,10 @@ func TestXmlWriter(t *testing.T) { raw, err := mv.XmlWriterRaw(w, "myRootTag") if err != nil { - t.Fatal("err:", err.Error()) + t.Fatal("err:",err.Error()) } - b := make([]byte, w.Len()) + b := make([]byte,w.Len()) _, err = w.Read(b) if err != nil { t.Fatal("err:", err.Error()) From 51032e9773fabb29e88629f239587f7ec1e8b286 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 19 Apr 2015 21:39:38 -0700 Subject: [PATCH 2/2] Fix incomplete progressBar problem, we should proactively .Finish() progressbar - fixes #452 Previously wouldn't flush out remaining data, it would work for Object Storage Get()/Put() due to invariable delays and overhead. --- cmd-cp-recursive.go | 5 +++++ cmd-cp.go | 5 ++++- pkg/client/fs/fs_put_unix.go | 5 ----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd-cp-recursive.go b/cmd-cp-recursive.go index 61f89244..49789559 100644 --- a/cmd-cp-recursive.go +++ b/cmd-cp-recursive.go @@ -24,6 +24,7 @@ import ( "github.com/cheggaaa/pb" "github.com/minio-io/mc/pkg/client" + "github.com/minio-io/mc/pkg/console" "github.com/minio-io/minio/pkg/iodine" ) @@ -164,6 +165,10 @@ func doCopyCmdRecursive(manager clientManager, sourceURL string, targetURLs []st return msg, err } } + if !globalDebugFlag { + bar.Finish() + console.Infoln("Success!") + } } return "", nil } diff --git a/cmd-cp.go b/cmd-cp.go index 12daf750..edb21312 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -112,7 +112,6 @@ func doCopyCmd(manager clientManager, sourceURL string, targetURLs []string) (st if err != nil { return "Copying data from source to target(s) failed", iodine.New(err, nil) } - // close writers for _, writer := range writeClosers { err := writer.Close() @@ -123,5 +122,9 @@ func doCopyCmd(manager clientManager, sourceURL string, targetURLs []string) (st if err != nil { return "Connections still active, one or more writes may of failed.", iodine.New(err, nil) } + if !globalQuietFlag { + bar.Finish() + console.Infoln("Success!") + } return "", nil } diff --git a/pkg/client/fs/fs_put_unix.go b/pkg/client/fs/fs_put_unix.go index 45f39059..d5ddb708 100644 --- a/pkg/client/fs/fs_put_unix.go +++ b/pkg/client/fs/fs_put_unix.go @@ -13,11 +13,6 @@ import ( // Put - upload new object to bucket func (f *fsClient) Put(md5HexString string, size int64) (io.WriteCloser, error) { - // Never create directories in here using bucket and object, since such a path might - // result in files being created as directories and prone to races. - // It should be 'PutBucket()' responsibility through the caller after validating - // through StatBucket() - r, w := io.Pipe() blockingWriter := NewBlockingWriteCloser(w) go func() {