forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgolines.go
41 lines (32 loc) · 1 KB
/
golines.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package golines
import (
"github.com/golangci/golines"
"github.com/golangci/golangci-lint/pkg/config"
)
const Name = "golines"
type Formatter struct {
shortener *golines.Shortener
}
func New(settings *config.GoLinesSettings) *Formatter {
options := golines.ShortenerConfig{}
if settings != nil {
options = golines.ShortenerConfig{
MaxLen: settings.MaxLen,
TabLen: settings.TabLen,
KeepAnnotations: false, // golines debug (not usable inside golangci-lint)
ShortenComments: settings.ShortenComments,
ReformatTags: settings.ReformatTags,
IgnoreGenerated: false, // handle globally
DotFile: "", // golines debug (not usable inside golangci-lint)
ChainSplitDots: settings.ChainSplitDots,
BaseFormatterCmd: "go fmt", // fake cmd
}
}
return &Formatter{shortener: golines.NewShortener(options)}
}
func (*Formatter) Name() string {
return Name
}
func (f *Formatter) Format(_ string, src []byte) ([]byte, error) {
return f.shortener.Shorten(src)
}