strictvar

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package strictvar provides an analysis.Analyzer that reduces the number of ways a variable may be declared.

strictvar is a formatter with type information. Whether a declaration carries a zero value is invisible to syntax alone, so these rules cannot live in a formatter, but running the fixes is meant to feel like running one.

Two ideas underlie every check. Zero values stay visually distinct, with no right-hand side and new(T) in place of &T{}, so declaring one reads as a deliberate act, and setting variables up ahead of use becomes the natural style. And where Go permits many spellings of one declaration, whether var or :=, typed or inferred, standalone or grouped, a single spelling is chosen.

strictvar is deliberately opinionated and likely over-strict. Whether it makes real code clearer can only be learned by running it against real code, so it ships as an experiment, expected to loosen as results come in.

Fixes are only suggested when there is exactly one obvious rewrite and no information is lost. A fix is withheld when it would remove a comment attached to nothing. Applying fixes can expose further fixes, so the tool may need to run more than once until all fixes apply cleanly. The README catalogs every check, exemption, and fix.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "strictvar",
	Doc:  "reports variable declarations that deviate from strict form",
	Run:  run,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
strictvar command

Jump to

Keyboard shortcuts

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