common

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package common contains constants, functions, and types that are used in more than one linter.

Index

Constants

View Source
const DocFilenameWithoutPath = "doc"

DocFilenameWithoutPath is the name of a file that can potentially hold a package document as opposed to a file of the same name as the package.

View Source
const FuncInit = "init"

FuncInit is a constant denoting the name of the "init" function that can exist in any package of a Go program.

View Source
const FuncMain = "main"

FuncMain is a constant denoting the name of the "main" function that exists in packageMain of a Go program.

View Source
const PackageMain = "main"

PackageMain is a constant denoting the name of the "main" package in a Go program.

Variables

This section is empty.

Functions

func IsGenerated

func IsGenerated(file *ast.File) bool

IsGenerated determines if the given file is a generated file.

Developer note: Periodically check whether or not this functionality is exposed in a stdlib package by looking at the status of this accepted proposal:

https://github.com/golang/go/issues/28089

Whenever it's added in a stdlib package, use that instead of this because it's likely going to have been implemented in a manner that is a lot smarter than this implementation.

func IsTestFile

func IsTestFile(pass *analysis.Pass, file *ast.File) bool

IsTestFile returns true if the filename is either test_*.go or *_test.go.

func IsTestPackage

func IsTestPackage(pass *analysis.Pass) bool

IsTestPackage determines whether or not the package for the current pass is a test package. The analysis.Analyzer is already smart enough to ignore "*_test.go" files, but sometimes there are explicit packages only meant to be used in tests. These are, or at least should be, suffixed with "test" (usually "_test").

func LoadOtherFilesIntoFset

func LoadOtherFilesIntoFset(pass *analysis.Pass) error

LoadOtherFilesIntoFset loads all files found in *analysis.Pass.OtherFiles into the Fset in *analysis.Pass.

Types

This section is empty.

Jump to

Keyboard shortcuts

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