resessh / mapkeyexistscheck

A lint program that enforces checking for the existence of a key when accessing a map.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mapkeyexistscheck

mapkeyexistscheck is a lint program that enforces checking for the existence of a key when accessing a map.

Install

go install github.com/resessh/mapkeyexistscheck/cmd/mapkeyexistscheck@latest

Usage

package main

func main()  {
  m := map[int]string{
    1: "1",
  }

  val := m[2]

  // ...
}
$ go vet -vettool=(which mapkeyexistscheck) ./...

main.go:8:2: map key exists check is not performed

About

A lint program that enforces checking for the existence of a key when accessing a map.

License:MIT License


Languages

Language:Go 100.0%