github.com/Johnny2210/revive@v1.0.8-0.20210625134200-febf37ccd0f5/formatter/plain.go (about)

     1  package formatter
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/mgechev/revive/lint"
     7  )
     8  
     9  // Plain is an implementation of the Formatter interface
    10  // which formats the errors to JSON.
    11  type Plain struct {
    12  	Metadata lint.FormatterMetadata
    13  }
    14  
    15  // Name returns the name of the formatter
    16  func (f *Plain) Name() string {
    17  	return "plain"
    18  }
    19  
    20  // Format formats the failures gotten from the lint.
    21  func (f *Plain) Format(failures <-chan lint.Failure, _ lint.Config) (string, error) {
    22  	for failure := range failures {
    23  		fmt.Printf("%v: %s %s\n", failure.Position.Start, failure.Failure, "https://revive.run/r#"+failure.RuleName)
    24  	}
    25  	return "", nil
    26  }