mapbreak

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 5 Imported by: 0

README

mapbreak

Detects if there is map reassignment in the range access.

Install

$go install github.com/convto/mapbreak/cmd/mapbreak@latest

Usage

The following is an example of code that writes to map with range access

package main

func main() {
	m := map[string]string{"a": "item a", "b": "item b"}
	for k, v := range m {
		m[k] = "reassigned: " + v
	}
}

Running go vet will result in the following

$ go vet -vettool=$(which mapbreak) ./...
# github.com/convto/mapbreak/testdata/src/singlefile
./singlefile.go:6:3: detected range access to map and reassigning

Documentation

Index

Constants

View Source
const Doc = "mapbreak detects if there is map reassignment in the range access"

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "mapbreak",
	Doc:  Doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL