Back to all reviewers

Choose appropriate API types

hashicorp/terraform
Based on 4 comments
Go

Select the simplest data types that satisfy requirements when designing API signatures. Avoid using complex types (like cty.Value) when simpler types (like string, int, bool) would suffice. This improves API usability, reduces complexity, and simplifies client implementations while maintaining consistent patterns across the API.

API Go

Reviewer Prompt

Select the simplest data types that satisfy requirements when designing API signatures. Avoid using complex types (like cty.Value) when simpler types (like string, int, bool) would suffice. This improves API usability, reduces complexity, and simplifies client implementations while maintaining consistent patterns across the API.

For example, prefer:

type GetStatesResponse struct {
    // States is a list of state names
    States []string
}

Instead of:

type GetStatesResponse struct {
    // States is a list of state names
    States []cty.Value
}

When extending existing APIs or adding new functionality, follow established naming and structural conventions to create a cohesive and predictable interface. Use helper functions provided by the API rather than reimplementing functionality, and ensure documentation accurately reflects method signatures, parameters, and return types to prevent confusion.

4
Comments Analyzed
Go
Primary Language
API
Category

Source Discussions