Skip to content

Add linter to error on unchecked map reads #3290

@mattysweeps

Description

@mattysweeps

Your feature request related to a problem? Please describe.

The following code sample highlights an issue where a map reference was unchecked (did not check ok == true) resulting in a nil pointer panic.

https://go.dev/play/p/XwjkvaEshlu

Describe the solution you'd like.

A linter to catch map references which only return 1 result, instead of both the value and the check.

Describe alternatives you've considered.

None

Additional context.

I looked at golangci-lint's linters but couldn't tell if this is already solved by existing linters.

I tested with golangci-lint 1.50.0 with flags --max-issues-per-linter 0 --enable-all --verbose but did not see any lint results related to the unsafe map usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions