// Implements the logic to compute the key of a given field’s entry
4073
func getFieldEntryKey(node *ast.Field) string {

	if node.Alias != nil && node.Alias.Value != "" {
		return node.Alias.Value
	}
	if node.Name != nil && node.Name.Value != "" {
		return node.Name.Value
	}
	return ""
}
386164
func (v *KeyValue_SetValue_Args) GetKey() (o string) {
	if v != nil && v.Key != nil {
		return *v.Key
	}

	return
}
1074395
func Key(s string) (*[32]byte, error) {
	if len(s) < 32 {
		return nil, errInvalidKeyLength
	}
	var key [32]byte
	copy(key[:], []byte(s))
	return &key, nil
}
707786
func NewFieldKey(obj map[string]interface{}, field string) FieldKey {
	return FieldKey{object: reflect.ValueOf(obj), field: field}
}
829844
func (kp *kmsKeyHandler) DecryptKey(key []byte) ([]byte, error) {
	out, err := kp.kms.Decrypt(&kms.DecryptInput{
		EncryptionContext: map[string]*string(kp.CipherData.MaterialDescription),
		CiphertextBlob:    key,
		GrantTokens:       []*string{},
	})
	if err != nil {
		return nil, err
	}
	return out.Plaintext, nil
}
807675
func KeyFrom(fields []string, doc Document) Key {
	key := make(Key, 0, len(fields))
	for _, f := range fields {
		if s, ok := doc[f].(String); ok {
			key = append(key, string(s))
		}
	}
	return key
}
324135
func (yfast *YFastTrie) Get(key uint64) Entry {
	entry := yfast.get(key)
	if entry == nil {
		return nil
	}

	return entry
}
90701
func (b *GCSBuilder) Key() ([gcs.KeySize]byte, error) {
	// Do nothing if the builder's errored out.
	if b.err != nil {
		return [gcs.KeySize]byte{}, b.err
	}

	return b.key, nil
}
942631
func (it *iterator) Key() []byte {
	if len(it.keys) > 0 {
		return []byte(it.keys[0])
	}
	return nil
}
672331
func getKeyFromDocument(doc reflect.Value) (string, error) {
	if doc.IsNil() {
		return "", WithStack(InvalidArgumentError{Message: "Document is nil"})
	}
	if doc.Kind() == reflect.Ptr {
		doc = doc.Elem()
	}
	switch doc.Kind() {
	case reflect.Struct:
		structType := doc.Type()
		fieldCount := structType.NumField()
		for i := 0; i < fieldCount; i++ {
			f := structType.Field(i)
			tagParts := strings.Split(f.Tag.Get("json"), ",")
			if tagParts[0] == "_key" {
				// We found the _key field
				keyVal := doc.Field(i)
				return keyVal.String(), nil
			}
		}
		return "", WithStack(InvalidArgumentError{Message: "Document contains no '_key' field"})
	case reflect.Map:
		keyVal := doc.MapIndex(reflect.ValueOf("_key"))
		if keyVal.IsNil() {
			return "", WithStack(InvalidArgumentError{Message: "Document contains no '_key' entry"})
		}
		return keyVal.String(), nil
	default:
		return "", WithStack(InvalidArgumentError{Message: fmt.Sprintf("Document must be struct or map. Got %s", doc.Kind())})
	}
}
27125
func DecodeRowKey(key string) (schema.MKey, int32, error) {
	parts := strings.SplitN(key, "_", 2)
	partition, err := strconv.Atoi(parts[0])
	if err != nil {
		return schema.MKey{}, 0, err
	}
	mkey, err := schema.MKeyFromString(parts[1])
	if err != nil {
		return schema.MKey{}, 0, err
	}
	return mkey, int32(partition), nil
}
941454
func (itr *memDBIterator) Key() []byte {
	itr.assertIsValid()
	return []byte(itr.keys[itr.cur])
}
1271149
func (c *Collection) FieldIndexKey(fieldName string) (string, error) {
	return c.spec.fieldIndexKey(fieldName)
}
701782
func (scope *Scope) PrimaryKeyValue() interface{} {
	if field := scope.PrimaryField(); field != nil && field.Field.IsValid() {
		return field.Field.Interface()
	}
	return 0
}
961340
func (c *cursor) Key() []byte {
	// Ensure transaction state is valid.
	if err := c.bucket.tx.checkClosed(); err != nil {
		return nil
	}

	// Nothing to return if cursor is exhausted.
	if c.currentIter == nil {
		return nil
	}

	// Slice out the actual key name and make a copy since it is no longer
	// valid after iterating to the next item.
	//
	// The key is after the bucket index prefix and parent ID when the
	// cursor is pointing to a nested bucket.
	key := c.currentIter.Key()
	if bytes.HasPrefix(key, bucketIndexPrefix) {
		key = key[len(bucketIndexPrefix)+4:]
		return copySlice(key)
	}

	// The key is after the bucket ID when the cursor is pointing to a
	// normal entry.
	key = key[len(c.bucket.id):]
	return copySlice(key)
}
1041367
func fieldWithKey(s interface{}, key string) (string, error) {
	st := reflect.TypeOf(s)
	if st.Kind() == reflect.Ptr {
		st = st.Elem()
	}

	for i := 0; i <= st.NumField()-1; i++ {
		field := st.Field(i)

		if confkey, ok := field.Tag.Lookup("confkey"); ok {
			if confkey == key {
				return field.Name, nil
			}
		}
	}

	return "", fmt.Errorf("can't find any structure element configured with confkey '%s'", key)
}
910289
func (entry *Entry) Field(name string) (value string, err error) {
	value, ok := entry.fields[name]
	if !ok {
		err = fmt.Errorf("field '%v' does not found in record %+v", name, *entry)
	}
	return
}