decorator

package module
v0.0.0-...-7fdf762 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 1 Imported by: 0

README

decorator

Go Reference test codecov

Library decorator wraps analyzers to supplement the results with additional details.

Before

internal/example/example.go:11:16: nil dereference in field selection

After

internal/example/example.go:11:16: 😱 nil dereference in field selection (nilness)

How to use

package main

import (
  "github.com/qawatake/decorator"

  "golang.org/x/tools/go/analysis"
  "golang.org/x/tools/go/analysis/passes/nilness"
  "golang.org/x/tools/go/analysis/unitchecker"
)

func main() {
  unitchecker.Main(
    decorator.With(
      func(a *analysis.Analyzer, d analysis.Diagnostic) analysis.Diagnostic {
        d.Message = "😱 " + d.Message + " (" + a.Name + ")"
        return d
      },
    )(nilness.Analyzer),
  )
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func WithName

func WithName() func(a *analysis.Analyzer) *analysis.Analyzer

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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