Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #3137

Merged
merged 1 commit into from
Jan 21, 2023
Merged

Cleanup #3137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions internal/descriptor/grpc_api_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (

func loadGrpcAPIServiceFromYAML(yamlFileContents []byte, yamlSourceLogName string) (*apiconfig.GrpcAPIService, error) {
var yamlContents interface{}
err := yaml.Unmarshal(yamlFileContents, &yamlContents)
if err != nil {
if err := yaml.Unmarshal(yamlFileContents, &yamlContents); err != nil {
return nil, fmt.Errorf("failed to parse gRPC API Configuration from YAML in %q: %w", yamlSourceLogName, err)
}

Expand Down Expand Up @@ -45,7 +44,7 @@ func registerHTTPRulesFromGrpcAPIService(registry *Registry, service *apiconfig.
for _, rule := range service.Http.GetRules() {
selector := "." + strings.Trim(rule.GetSelector(), " ")
if strings.ContainsAny(selector, "*, ") {
return fmt.Errorf("selector '%v' in %v must specify a single service method without wildcards", rule.GetSelector(), sourceLogName)
return fmt.Errorf("selector %q in %v must specify a single service method without wildcards", rule.GetSelector(), sourceLogName)
}

registry.AddExternalHTTPRule(selector, rule)
Expand Down
7 changes: 3 additions & 4 deletions internal/descriptor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func (r *Registry) ReserveGoPackageAlias(alias, pkgpath string) error {

// GetAllFQMNs returns a list of all FQMNs
func (r *Registry) GetAllFQMNs() []string {
var keys []string
keys := make([]string, 0, len(r.msgs))
for k := range r.msgs {
keys = append(keys, k)
}
Expand All @@ -439,7 +439,7 @@ func (r *Registry) GetAllFQMNs() []string {

// GetAllFQENs returns a list of all FQENs
func (r *Registry) GetAllFQENs() []string {
var keys []string
keys := make([]string, 0, len(r.enums))
for k := range r.enums {
keys = append(keys, k)
}
Expand Down Expand Up @@ -749,8 +749,7 @@ func (r *Registry) FieldName(f *Field) string {

func (r *Registry) CheckDuplicateAnnotation(httpMethod string, httpTemplate string, svc *Service) error {
a := annotationIdentifier{method: httpMethod, pathTemplate: httpTemplate, service: svc}
_, ok := r.annotationMap[a]
if ok {
if _, ok := r.annotationMap[a]; ok {
return fmt.Errorf("duplicate annotation: method=%s, template=%s", httpMethod, httpTemplate)
}
r.annotationMap[a] = struct{}{}
Expand Down
2 changes: 1 addition & 1 deletion internal/descriptor/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ type FieldPath []FieldPathComponent

// String returns a string representation of the field path.
func (p FieldPath) String() string {
var components []string
components := make([]string, 0, len(p))
for _, c := range p {
components = append(components, c.Name)
}
Expand Down