analyzer

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package analyzer is a linter that reports ignored constructors. It shows you places where someone is doing T{} or &T{} instead of using NewT declared in the same package as T. A constructor for type T (only structs are supported at the moment) is a function with name "NewT" that returns a value of type T or *T. Types returned by constructors are not checked right now, only that type T inferred from the function name exists in the same package. Standard library packages are excluded from analysis.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:      "constructor_check",
	Doc:       "check for types constructed manually ignoring constructor",
	Run:       run,
	Requires:  []*analysis.Analyzer{inspect.Analyzer},
	FactTypes: []analysis.Fact{(*ConstructorFact)(nil)},
}

Functions

This section is empty.

Types

type ConstructorFact

type ConstructorFact struct {
	ConstructorName string
	Pos             token.Pos
	End             token.Pos
}

func (*ConstructorFact) AFact

func (f *ConstructorFact) AFact()

Jump to

Keyboard shortcuts

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