github.com/songshiyun/revive@v1.1.5-0.20220323112655-f8433a19b3c5/formatter/default.go (about)

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