LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package xml | 5 package xml |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "reflect" | 9 "reflect" |
10 "strings" | 10 "strings" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 tinfoLock.Unlock() | 106 tinfoLock.Unlock() |
107 return tinfo, nil | 107 return tinfo, nil |
108 } | 108 } |
109 | 109 |
110 // structFieldInfo builds and returns a fieldInfo for f. | 110 // structFieldInfo builds and returns a fieldInfo for f. |
111 func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro
r) { | 111 func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, erro
r) { |
112 finfo := &fieldInfo{idx: f.Index} | 112 finfo := &fieldInfo{idx: f.Index} |
113 | 113 |
114 // Split the tag from the xml namespace if necessary. | 114 // Split the tag from the xml namespace if necessary. |
115 tag := f.Tag.Get("xml") | 115 tag := f.Tag.Get("xml") |
116 » if i := strings.IndexByte(tag, ' '); i >= 0 { | 116 » if i := strings.Index(tag, " "); i >= 0 { |
117 finfo.xmlns, tag = tag[:i], tag[i+1:] | 117 finfo.xmlns, tag = tag[:i], tag[i+1:] |
118 } | 118 } |
119 | 119 |
120 // Parse flags. | 120 // Parse flags. |
121 tokens := strings.Split(tag, ",") | 121 tokens := strings.Split(tag, ",") |
122 if len(tokens) == 1 { | 122 if len(tokens) == 1 { |
123 finfo.flags = fElement | 123 finfo.flags = fElement |
124 } else { | 124 } else { |
125 tag = tokens[0] | 125 tag = tokens[0] |
126 for _, flag := range tokens[1:] { | 126 for _, flag := range tokens[1:] { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 if v.IsNil() { | 351 if v.IsNil() { |
352 v.Set(reflect.New(v.Type().Elem())) | 352 v.Set(reflect.New(v.Type().Elem())) |
353 } | 353 } |
354 v = v.Elem() | 354 v = v.Elem() |
355 } | 355 } |
356 } | 356 } |
357 v = v.Field(x) | 357 v = v.Field(x) |
358 } | 358 } |
359 return v | 359 return v |
360 } | 360 } |
LEFT | RIGHT |