diff --git a/src/github.com/mickep76/common/version.go b/src/github.com/mickep76/common/version.go index 77d838f..628f563 100644 --- a/src/github.com/mickep76/common/version.go +++ b/src/github.com/mickep76/common/version.go @@ -1,4 +1,4 @@ package common // Version -const Version = "0.6" +const Version = "0.7" diff --git a/src/github.com/mickep76/etcd-import/etcd-import.go b/src/github.com/mickep76/etcd-import/etcd-import.go index 63b1f30..2658df9 100644 --- a/src/github.com/mickep76/etcd-import/etcd-import.go +++ b/src/github.com/mickep76/etcd-import/etcd-import.go @@ -50,7 +50,7 @@ func main() { } // Setup Etcd client. - if *node == "" { + if *node != "" { conn = []string{fmt.Sprintf("http://%v:%v", *node, *port)} } client := etcd.NewClient(conn) diff --git a/vendor/manifest b/vendor/manifest index 1590716..7324d6c 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -17,7 +17,7 @@ { "importpath": "github.com/mickep76/etcdmap", "repository": "https://github.com/mickep76/etcdmap", - "revision": "3dc145c669a773963370d390afd50a89c36cfc97", + "revision": "87c4403f69d72d43abc584a638d78958ce22e3b4", "branch": "master" }, { @@ -29,7 +29,7 @@ { "importpath": "github.com/ugorji/go/codec", "repository": "https://github.com/ugorji/go", - "revision": "5c83d75b24f35bd4b4a03bdfba76a2cbcce76e36", + "revision": "44024c561b3b217e190440d74b97dd254f8e52e8", "branch": "master", "path": "/codec" }, diff --git a/vendor/src/github.com/mickep76/etcdmap/etcdmap.go b/vendor/src/github.com/mickep76/etcdmap/etcdmap.go index 156101c..428cbe8 100644 --- a/vendor/src/github.com/mickep76/etcdmap/etcdmap.go +++ b/vendor/src/github.com/mickep76/etcdmap/etcdmap.go @@ -71,7 +71,22 @@ func Map(root *etcd.Node) map[string]interface{} { // Create Etcd directory structure from a map, slice or struct. func Create(client *etcd.Client, path string, val reflect.Value) error { + // fmt.Printf("# %s : %s : %s\n", path, val.Kind(), val.Type()) + switch val.Kind() { + case reflect.Ptr: + orig := val.Elem() + if !orig.IsValid() { + return nil + } + if err := Create(client, path, orig); err != nil { + return err + } + case reflect.Interface: + orig := val.Elem() + if err := Create(client, path, orig); err != nil { + return err + } case reflect.Struct: for i := 0; i < val.NumField(); i++ { t := val.Type().Field(i) diff --git a/vendor/src/github.com/ugorji/go/codec/encode.go b/vendor/src/github.com/ugorji/go/codec/encode.go index e480ed5..481626b 100644 --- a/vendor/src/github.com/ugorji/go/codec/encode.go +++ b/vendor/src/github.com/ugorji/go/codec/encode.go @@ -874,7 +874,8 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder { // The empty values (for omitempty option) are false, 0, any nil pointer // or interface value, and any array, slice, map, or string of length zero. // -// Anonymous fields are encoded inline if no struct tag is present. +// Anonymous fields are encoded inline if the struct tag is "effectively" blank +// i.e. it is not present or does not have any parameters specified. // Else they are encoded as regular fields. // // Examples: diff --git a/vendor/src/github.com/ugorji/go/codec/helper.go b/vendor/src/github.com/ugorji/go/codec/helper.go index 7848ea1..6d60e57 100644 --- a/vendor/src/github.com/ugorji/go/codec/helper.go +++ b/vendor/src/github.com/ugorji/go/codec/helper.go @@ -471,6 +471,10 @@ type structFieldInfo struct { toArray bool // if field is _struct, is the toArray set? } +func (si *structFieldInfo) isZero() bool { + return si.encName == "" && len(si.is) == 0 && si.i == 0 && !si.omitEmpty && !si.toArray +} + // rv returns the field of the struct. // If anonymous, it returns an Invalid func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value) { @@ -516,9 +520,9 @@ func (si *structFieldInfo) setToZeroValue(v reflect.Value) { } func parseStructFieldInfo(fname string, stag string) *structFieldInfo { - if fname == "" { - panic(noFieldNameToStructFieldInfoErr) - } + // if fname == "" { + // panic(noFieldNameToStructFieldInfoErr) + // } si := structFieldInfo{ encName: fname, } @@ -723,8 +727,20 @@ func rgetTypeInfo(rt reflect.Type, indexstack []int, fnameToHastag map[string]bo if r1, _ := utf8.DecodeRuneInString(f.Name); r1 == utf8.RuneError || !unicode.IsUpper(r1) { continue } - // if anonymous and there is no struct tag and its a struct (or pointer to struct), inline it. - if f.Anonymous && stag == "" { + var si *structFieldInfo + // if anonymous and there is no struct tag (or it's blank) + // and its a struct (or pointer to struct), inline it. + var doInline bool + if f.Anonymous { + doInline = stag == "" + if !doInline { + si = parseStructFieldInfo("", stag) + doInline = si.isZero() + // fmt.Printf(">>>> doInline for si.isZero: %s: %v\n", f.Name, doInline) + } + } + + if doInline { ft := f.Type for ft.Kind() == reflect.Ptr { ft = ft.Elem() @@ -744,7 +760,14 @@ func rgetTypeInfo(rt reflect.Type, indexstack []int, fnameToHastag map[string]bo if _, ok := fnameToHastag[f.Name]; ok { continue } - si := parseStructFieldInfo(f.Name, stag) + if f.Name == "" { + panic(noFieldNameToStructFieldInfoErr) + } + if si == nil { + si = parseStructFieldInfo(f.Name, stag) + } else if si.encName == "" { + si.encName = f.Name + } // si.ikind = int(f.Type.Kind()) if len(indexstack) == 0 { si.i = int16(j)