Skip to content

x/tools/go/analysis/passes/composite: flag to require keys within same package #73953

Open
@arxeiss

Description

@arxeiss

I would like to suggest improvement to existing Vet Composite linter.

Currently, composite requires struct field names to be specified only, if given type is defined in different package. However, I believe, same restrictions should be done for type within same package. Because if some struct is used in many places, adding 1 field requires changed everywhere. Even, if it is irrelevant and I would be specifying only empty value.

Not to introduce breaking change, it would be possible to turn this on by flag.

Meaning all those selected lines (30 - 68) would be raising issue https://cs.opensource.google/go/x/tools/+/effd83eb4d44f4443100debb7ede6619a4ac6528:go/analysis/passes/composite/testdata/src/a/a.go;l=30-68

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions