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

     1  package formatter
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/mgechev/revive/lint"
     7  )
     8  
     9  // Unix is an implementation of the Formatter interface
    10  // which formats the errors to a simple line based error format
    11  //  main.go:24:9: [errorf] should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)
    12  type Unix struct {
    13  	Metadata lint.FormatterMetadata
    14  }
    15  
    16  // Name returns the name of the formatter
    17  func (f *Unix) Name() string {
    18  	return "unix"
    19  }
    20  
    21  // Format formats the failures gotten from the lint.
    22  func (f *Unix) Format(failures <-chan lint.Failure, _ lint.Config) (string, error) {
    23  	for failure := range failures {
    24  		fmt.Printf("%v: [%s] %s\n", failure.Position.Start, failure.RuleName, failure.Failure)
    25  	}
    26  	return "", nil
    27  }