1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-10 03:17:11 +02:00
revive/formatter/default.go

29 lines
629 B
Go
Raw Normal View History

2018-01-28 03:01:18 +02:00
package formatter
import (
"bytes"
2018-01-28 03:01:18 +02:00
"fmt"
"github.com/mgechev/revive/lint"
)
// Default is an implementation of the Formatter interface
// which formats the errors to text.
2018-01-28 03:01:18 +02:00
type Default struct {
Metadata lint.FormatterMetadata
}
// Name returns the name of the formatter
2022-04-10 11:55:13 +02:00
func (*Default) Name() string {
2018-01-28 03:01:18 +02:00
return "default"
}
// Format formats the failures gotten from the lint.
2022-04-10 11:55:13 +02:00
func (*Default) Format(failures <-chan lint.Failure, _ lint.Config) (string, error) {
var buf bytes.Buffer
2018-01-28 03:01:18 +02:00
for failure := range failures {
fmt.Fprintf(&buf, "%v: %s\n", failure.Position.Start, failure.Failure)
2018-01-28 03:01:18 +02:00
}
return buf.String(), nil
2018-01-28 03:01:18 +02:00
}