field: add IsEmbedded and fix doc about Value()

This commit is contained in:
Fatih Arslan 2014-08-10 15:53:25 +03:00
parent fe137c012f
commit 53f565ab3e

View File

@ -2,19 +2,25 @@ package structure
import "reflect"
// Field represents a single struct field that encapsulates many high level
// function around a singel struct field
// Field represents a single struct field that encapsulates high level
// functions around the field.
type Field struct {
value reflect.Value
field reflect.StructField
}
// Tag returns the value associated with key in the tag string. If there is no
// such key in the tag, Tag returns the empty string
// such key in the tag, Tag returns the empty string.
func (f *Field) Tag(key string) string {
return f.field.Tag.Get(key)
}
// Value returns the underlying value of of the field.
func (f *Field) Value() interface{} {
return f.value.Interface()
}
// IsEmbedded returns true if the given field is an anonymous field (embedded)
func (f *Field) IsEmbedded() bool {
return f.field.Anonymous
}