Skip to content

cmd/vet: flag simple nil pointer dereferences for struct field usage and nil map assignments #39462

@odeke-em

Description

@odeke-em

Coming here from an experience report narrated to me offline by @kastiglione and @indragiek.

The code below is biting yet can be trivially flagged by cmd/vet

Usage of field in an obvious nil struct

https://play.golang.org/p/i_a3kGE61UZ
724716BA-8467-4A68-8D9D-3F30840DC6FB

Assignment to a nil map

https://play.golang.org/p/KlN7AY1U4lo
5FA92B7F-78A6-4410-B9F1-8FDE1F551504

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.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions