Skip to content

Commit 2600dff

Browse files
committed
replace Run with RunRewrite
1 parent 568a786 commit 2600dff

File tree

1 file changed

+1
-35
lines changed

1 file changed

+1
-35
lines changed

gofmt/golangci.go

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,12 @@ import (
66
"go/ast"
77
"go/parser"
88
"go/printer"
9-
"io/ioutil"
109
"os"
1110
"strings"
1211
)
1312

1413
func Run(filename string, needSimplify bool) ([]byte, error) {
15-
src, err := ioutil.ReadFile(filename)
16-
if err != nil {
17-
return nil, err
18-
}
19-
20-
initParserMode()
21-
22-
file, sourceAdj, indentAdj, err := parse(fileSet, filename, src, false)
23-
if err != nil {
24-
return nil, err
25-
}
26-
27-
ast.SortImports(fileSet, file)
28-
29-
if needSimplify {
30-
simplify(file)
31-
}
32-
33-
res, err := format(fileSet, file, sourceAdj, indentAdj, src, printer.Config{Mode: printerMode, Tabwidth: tabWidth})
34-
if err != nil {
35-
return nil, err
36-
}
37-
38-
if bytes.Equal(src, res) {
39-
return nil, nil
40-
}
41-
42-
// formatting has changed
43-
data, err := diff(src, res, filename)
44-
if err != nil {
45-
return nil, fmt.Errorf("error computing diff: %s", err)
46-
}
47-
48-
return data, nil
14+
return RunRewrite(filename, needSimplify, "")
4915
}
5016

5117
func RunRewrite(filename string, needSimplify bool, rewrite string) ([]byte, error) {

0 commit comments

Comments
 (0)