Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(669)

Unified Diff: src/pkg/reflect/value.go

Issue 837042: code review 837042: Add support for XML marshalling embedded structs. (Closed)
Patch Set: code review 837042: Add support for XML marshalling embedded structs. Created 14 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/reflect/type.go ('k') | src/pkg/xml/embed_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/reflect/value.go
===================================================================
--- a/src/pkg/reflect/value.go
+++ b/src/pkg/reflect/value.go
@@ -1251,6 +1251,16 @@
return nil
}
+// FieldByNameFunc returns the struct field with a name that satisfies the
+// match function.
+// The result is nil if no field was found.
+func (t *StructValue) FieldByNameFunc(match func(string) bool) Value {
+ if f, ok := t.Type().(*StructType).FieldByNameFunc(match); ok {
+ return t.FieldByIndex(f.Index)
+ }
+ return nil
+}
+
// NumField returns the number of fields in the struct.
func (v *StructValue) NumField() int { return v.typ.(*StructType).NumField() }
« no previous file with comments | « src/pkg/reflect/type.go ('k') | src/pkg/xml/embed_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b