mirror of
https://github.com/mgechev/revive.git
synced 2025-09-16 09:06:22 +02:00
New formatter: unix (#65)
This commit is contained in:
committed by
Minko Gechev
parent
2387290dcf
commit
2e16582cbc
@@ -72,6 +72,7 @@ var allFormatters = []lint.Formatter{
|
||||
&formatter.JSON{},
|
||||
&formatter.NDJSON{},
|
||||
&formatter.Default{},
|
||||
&formatter.Unix{},
|
||||
&formatter.Checkstyle{},
|
||||
}
|
||||
|
||||
|
27
formatter/unix.go
Normal file
27
formatter/unix.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package formatter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mgechev/revive/lint"
|
||||
)
|
||||
|
||||
// Unix is an implementation of the Formatter interface
|
||||
// which formats the errors to a simple line based error format
|
||||
// main.go:24:9: [errorf] should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...)
|
||||
type Unix struct {
|
||||
Metadata lint.FormatterMetadata
|
||||
}
|
||||
|
||||
// Name returns the name of the formatter
|
||||
func (f *Unix) Name() string {
|
||||
return "unix"
|
||||
}
|
||||
|
||||
// Format formats the failures gotten from the lint.
|
||||
func (f *Unix) Format(failures <-chan lint.Failure, config lint.RulesConfig) (string, error) {
|
||||
for failure := range failures {
|
||||
fmt.Printf("%v: [%s] %s\n", failure.Position.Start, failure.RuleName, failure.Failure)
|
||||
}
|
||||
return "", nil
|
||||
}
|
Reference in New Issue
Block a user