toolshonnef.co/go/tools/internal/sharedcheck Index | Files

package sharedcheck

import "honnef.co/go/tools/internal/sharedcheck"

Index

Functions

func CheckRangeStringRunes

func CheckRangeStringRunes(pass *analysis.Pass) (interface{}, error)

func RedundantTypeInDeclarationChecker

func RedundantTypeInDeclarationChecker(verb string, flagHelpfulTypes bool) *analysis.Analyzer

RedundantTypeInDeclarationChecker returns a checker that flags variable declarations with redundantly specified types. That is, it flags 'var v T = e' where e's type is identical to T and 'var v = e' (or 'v := e') would have the same effect.

It does not flag variables under the following conditions, to reduce the number of false positives: - global variables – these often specify types to aid godoc - files that use cgo – cgo code generation and pointer checking emits redundant types

It does not flag variables under the following conditions, unless flagHelpfulTypes is true, to reduce the number of noisy positives: - packages that import syscall or unsafe – these sometimes use this form of assignment to make sure types are as expected - variables named the blank identifier – a pattern used to confirm the types of variables - untyped expressions on the rhs – the explicitness might aid readability

Source Files

lint.go

Version
v0.6.0-0.dev
Published
Aug 13, 2024
Platform
linux/amd64
Imports
16 packages
Last checked
46 minutes ago

Tools for package owners.