hashicorp / terraform-plugin-codegen-spec

Terraform Provider Code Generation Specification and Go Bindings
Mozilla Public License 2.0
7 stars 4 forks source link

Add helpers for types with string pointer fields #11

Closed bendbennett closed 1 year ago

bendbennett commented 1 year ago

During the process of generating code from an intermediate representation, it is currently necessary to perform checks to determine whether particular code snippets should be generated. For example, during the generation of import statements, checks such as the following are required to determine whether to add an import for a custom type:

    if g.CustomType != nil {
        if g.CustomType.Import != nil && *g.CustomType.Import != "" {
            .........                

Helpers could be introduced to clean-up and simplify this process, for instance:

func (t CustomType) HasImport() bool {
    return t.Import != nil && *t.Import != ""
}
github-actions[bot] commented 3 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.