Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ljmsc committed Jan 29, 2024
1 parent 15e1c5b commit 7128b99
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
1 change: 0 additions & 1 deletion examples/internal/proto/examplepb/echo_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ message SimpleMessage {
}
string resource_id = 8;
NestedMessage n_id = 9;

}

// DynamicMessage represents a message which can have its structure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ message UnannotatedSimpleMessage {
}
string resource_id = 9;
UnannotatedNestedMessage n_id = 10;

}

// Echo service responds to incoming echo requests.
Expand Down
34 changes: 0 additions & 34 deletions runtime/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,6 @@ func normalizeFieldPath(msgValue protoreflect.Message, fieldPath []string) []str
return newFieldPath
}

func findFieldFromPath(msgValue protoreflect.Message, fieldPath []string) (protoreflect.Message, protoreflect.FieldDescriptor, []string, error) {
if len(fieldPath) < 1 {
return nil, nil, nil, errors.New("no field path")
}

newFieldPath := make([]string, 0, len(fieldPath))
for i, fieldName := range fieldPath {
fields := msgValue.Descriptor().Fields()
fieldDesc := fields.ByTextName(fieldName)
if fieldDesc == nil {
fieldDesc = fields.ByJSONName(fieldName)
}
if fieldDesc == nil {
return nil, nil, fieldPath, nil
}

newFieldPath = append(newFieldPath, string(fieldDesc.Name()))

// If this is the last element, we're done
if i == len(fieldPath)-1 {
return msgValue, fieldDesc, newFieldPath, nil
}

if fieldDesc.Message() == nil || fieldDesc.Cardinality() == protoreflect.Repeated {
return nil, nil, nil, fmt.Errorf("invalid path %v: %q is not a message", fieldPath, fieldName)
}

// Get the nested message
msgValue = msgValue.Mutable(fieldDesc).Message()
}

return nil, nil, nil, fmt.Errorf("invalid path %v", fieldPath)
}

func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []string, values []string) error {
if len(fieldPath) < 1 {
return errors.New("no field path")
Expand Down

0 comments on commit 7128b99

Please sign in to comment.