Documentation
¶
Index ¶
- func Is[T any](ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)
- func IsFuncCall(ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)
- func IsImport(ctx context.Context, n ast.Node, pass *analysis.Pass) (context.Context, bool)
- type Checker
- type DDTraceTypes
- type KnownChange
- type Probe
- type TraceIDString
- type TracerStructs
- type V1ImportURL
- type WithServiceName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Is ¶
Is returns true if the node is of type T. The type use in the generic signature is stored in the context as "type".
func IsFuncCall ¶
IsFuncCall returns true if the node is a function call. The function call expression is stored in the context as "fn". The package path of the function is stored as "pkg_path". The parameters of the function are stored as "args".
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
func NewChecker ¶
func NewChecker(knownChanges ...KnownChange) *Checker
type DDTraceTypes ¶
type DDTraceTypes struct {
// contains filtered or unexported fields
}
func (DDTraceTypes) Fixes ¶
func (c DDTraceTypes) Fixes() []analysis.SuggestedFix
func (DDTraceTypes) Probes ¶
func (DDTraceTypes) Probes() []Probe
func (DDTraceTypes) String ¶
func (DDTraceTypes) String() string
type KnownChange ¶
type KnownChange interface {
fmt.Stringer
// Context returns the context associated with the known change.
Context() context.Context
// Fixes returns a list of fixes that can be applied to the analyzed expression.
Fixes() []analysis.SuggestedFix
// Probes returns a list of probes that must be true to report the analyzed expression.
Probes() []Probe
// SetContext updates the context with the given value.
SetContext(context.Context)
// SetNode updates the node with the given value.
SetNode(ast.Node)
}
KnownChange models code expressions that must be changed to migrate to v2. It is defined by a set of probes that must be true to report the analyzed expression. It also contains a message function that returns a string describing the change. The probes are evaluated in order, and the first one that returns false will cause the expression to be ignored. A probe can store information in the context, which is available to the following ones. It is possible to declare fixes that will be suggested to the user or applied automatically.
type Probe ¶
func DeclaresType ¶
DeclaresType returns true if the node declares a type of the given generic type. The type use in the generic signature is stored in the context as "type". The reflected type is stored in the context as "declared_type".
func HasPackagePrefix ¶
HasPackagePrefix returns true if the selector expression has a package prefix. The package path is expected in the context as "pkg_path".
func ImportedFrom ¶
ImportedFrom returns true if the value is imported from the given package path prefix.
func WithFunctionName ¶
type TraceIDString ¶
type TraceIDString struct {
// contains filtered or unexported fields
}
func (TraceIDString) Fixes ¶
func (c TraceIDString) Fixes() []analysis.SuggestedFix
func (TraceIDString) Probes ¶
func (c TraceIDString) Probes() []Probe
func (TraceIDString) String ¶
func (c TraceIDString) String() string
type TracerStructs ¶
type TracerStructs struct {
// contains filtered or unexported fields
}
func (TracerStructs) Fixes ¶
func (c TracerStructs) Fixes() []analysis.SuggestedFix
func (TracerStructs) Probes ¶
func (TracerStructs) Probes() []Probe
func (TracerStructs) String ¶
func (TracerStructs) String() string
type V1ImportURL ¶
type V1ImportURL struct {
// contains filtered or unexported fields
}
func (V1ImportURL) Fixes ¶
func (c V1ImportURL) Fixes() []analysis.SuggestedFix
func (V1ImportURL) Probes ¶
func (V1ImportURL) Probes() []Probe
func (V1ImportURL) String ¶
func (V1ImportURL) String() string
type WithServiceName ¶
type WithServiceName struct {
// contains filtered or unexported fields
}
func (WithServiceName) Fixes ¶
func (c WithServiceName) Fixes() []analysis.SuggestedFix
func (WithServiceName) Probes ¶
func (c WithServiceName) Probes() []Probe
func (WithServiceName) String ¶
func (c WithServiceName) String() string