// field is of form: key="value"
190510
func lexField(r *strings.Reader) (string, string, error) {
	key := make([]byte, 0, 5)
	val := make([]byte, 0, 32)

	// read the key
	for {
		ch, _ := r.ReadByte()
		if ch == '=' {
			break
		}
		if ch < 'a' || ch > 'z' { // fail if not ASCII lowercase letter
			return "", "", AuthFormatError{"header", "cannot parse header field"}
		}
		key = append(key, ch)
	}
	if ch, _ := r.ReadByte(); ch != '"' {
		return "", "", AuthFormatError{string(key), "cannot parse value"}
	}
	// read the value
	for {
		ch, _ := r.ReadByte()
		if ch == '"' {
			break
		}
		// character class is ASCII printable [\x20-\x7E] without \ and "
		if ch < 0x20 || ch > 0x7E || ch == '\\' {
			return "", "", AuthFormatError{string(key), "cannot parse value"}
		}
		val = append(val, ch)
	}

	return string(key), string(val), nil
}
377536
func GetKeyField(keyString string, v reflect.Value) reflect.Value {
	return v.Elem().FieldByName(keyString)
}
130553
func (s *Scrubber) fields(rv reflect.Value, path Path, callbacks map[string]Path) {
	for i := 0; i < rv.NumField(); i++ {
		sf := rv.Type().Field(i)
		if sf.PkgPath != "" && !sf.Anonymous { // unexported.
			continue
		}

		// dnode uses JSON package tags for field naming so we need to
		// discard their comma-separated options.
		tag := sf.Tag.Get("json")
		if idx := strings.Index(tag, ","); idx != -1 {
			tag = tag[:idx]
		}
		if tag == "-" {
			continue
		}
		// do not collect callbacks for "-" tagged fields.
		if skip := sf.Tag.Get("dnode"); skip == "-" {
			continue
		}

		var name = tag
		if name == "" {
			name = sf.Name
		}

		if sf.Anonymous {
			s.collect(rv.Field(i), path, callbacks)
		} else {
			s.collect(rv.Field(i), append(path, name), callbacks)
		}
	}
}
1198762
func (q *PrefixQuery) Field(field string) *PrefixQuery {
	q.options["field"] = field
	return q
}
647794
func (s *SearchService) DocvalueField(docvalueField string) *SearchService {
	s.searchSource = s.searchSource.DocvalueField(docvalueField)
	return s
}
272618
func (b *CollapseBuilder) Field(field string) *CollapseBuilder {
	b.field = field
	return b
}
206239
func (a *CompositeAggregationHistogramValuesSource) Field(field string) *CompositeAggregationHistogramValuesSource {
	a.field = field
	return a
}
250856
func SetField(s interface{}, name string, value interface{}) error {
	return setField(reflect.ValueOf(s), name, name, value)
}
1098442
func (d *DashField) Field(path []string) (string, error) {
	np := d.clean(path)
	return strings.ToLower(strings.Join(np, "-")), nil
}
802396
func (q *TermRangeQuery) Field(field string) *TermRangeQuery {
	q.options["field"] = field
	return q
}
668223
func (q *MatchQuery) Field(field string) *MatchQuery {
	q.options["field"] = field
	return q
}
392037
func SetField(obj interface{}, name string, value interface{}) error {
	structValue := reflect.ValueOf(obj).Elem()
	structFieldValue := structValue.FieldByName(name)

	if !structFieldValue.IsValid() {
		return fmt.Errorf("No such field: %s in obj", name)
	}

	if !structFieldValue.CanSet() {
		return fmt.Errorf("Cannot set %s field value", name)
	}

	structFieldType := structFieldValue.Type()
	val := reflect.ValueOf(value)
	if structFieldType != val.Type() {
		invalidTypeError := errors.New("Provided value type didn't match obj field type")
		return invalidTypeError
	}

	structFieldValue.Set(val)
	return nil
}
286672
func (m *ContainerUpdate) Field(fieldpath []string) (string, bool) {
	if len(fieldpath) == 0 {
		return "", false
	}

	switch fieldpath[0] {
	case "id":
		return string(m.ID), len(m.ID) > 0
	case "image":
		return string(m.Image), len(m.Image) > 0
	case "labels":
		// Labels fields have been special-cased by name. If this breaks,
		// add better special casing to fieldpath plugin.
		if len(m.Labels) == 0 {
			return "", false
		}
		value, ok := m.Labels[strings.Join(fieldpath[1:], ".")]
		return value, ok
	case "snapshot_key":
		return string(m.SnapshotKey), len(m.SnapshotKey) > 0
	}
	return "", false
}
1152934
func F(key string, value interface{}) Field {
	return Field{Key: key, Value: value}
}
854127
func (e *Entry) WithField(key string, value interface{}) *Entry {
	return e.WithFields(Fields{key: value})
}
747069
func (f *Form) Value(name string) (string, error) {
	if _, ok := f.fields[name]; ok {
		return f.fields.Get(name), nil
	}
	return "", errors.NewElementNotFound("No input found with name '%s'.", name)
}
1115364
func (document Document) Field(field string) interface{} {
	r, _ := document.Fields[field]
	return r
}