File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 36
36
defaultOutpout io.Writer = os .Stdout
37
37
)
38
38
39
+ func main () {
40
+ if err := buildMainCommand ().Execute (); err != nil {
41
+ fmt .Println (fmt .Errorf ("%v" , err ))
42
+ os .Exit (1 )
43
+ }
44
+ }
45
+
39
46
type ReorderConfig struct {
40
47
FormatToolName string `yaml:"format"`
41
48
Write bool `yaml:"write"`
@@ -45,13 +52,6 @@ type ReorderConfig struct {
45
52
DefOrder []string `yaml:"order"`
46
53
}
47
54
48
- func main () {
49
- if err := buildMainCommand ().Execute (); err != nil {
50
- fmt .Println (fmt .Errorf ("%v" , err ))
51
- os .Exit (1 )
52
- }
53
- }
54
-
55
55
func processFile (fileOrDirectoryName string , input []byte , config * ReorderConfig ) {
56
56
if strings .HasSuffix (fileOrDirectoryName , "_test.go" ) {
57
57
log .Println ("Skipping test file: " + fileOrDirectoryName )
Original file line number Diff line number Diff line change 12
12
logger * l.Logger
13
13
)
14
14
15
+ func init () {
16
+ // set the log output to stderr
17
+ logger = l .New (os .Stderr , "" , l .LstdFlags )
18
+ }
19
+
15
20
func GetLogger () * l.Logger {
16
21
return logger
17
22
}
@@ -26,8 +31,3 @@ func SetVerbose(v bool) {
26
31
logger .SetOutput (writer )
27
32
}
28
33
}
29
-
30
- func init () {
31
- // set the log output to stderr
32
- logger = l .New (os .Stderr , "" , l .LstdFlags )
33
- }
Original file line number Diff line number Diff line change @@ -90,19 +90,16 @@ func processConst(
90
90
return source
91
91
}
92
92
93
- func processFunctions (
93
+ func processExtractedFunction (
94
94
info * ParsedInfo ,
95
95
functionNames , originalContent , source []string ,
96
96
removedLines , lineNumberWhereInject * int ,
97
97
sign string ,
98
- extactinit , extactmain bool ,
98
+ funcname string ,
99
99
) []string {
100
100
for _ , name := range functionNames {
101
101
102
- if name == "init" && extactinit {
103
- continue
104
- }
105
- if name == "main" && extactmain {
102
+ if funcname != name {
106
103
continue
107
104
}
108
105
@@ -119,16 +116,19 @@ func processFunctions(
119
116
return source
120
117
}
121
118
122
- func processExtractedFunction (
119
+ func processFunctions (
123
120
info * ParsedInfo ,
124
121
functionNames , originalContent , source []string ,
125
122
removedLines , lineNumberWhereInject * int ,
126
123
sign string ,
127
- funcname string ,
124
+ extactinit , extactmain bool ,
128
125
) []string {
129
126
for _ , name := range functionNames {
130
127
131
- if funcname != name {
128
+ if name == "init" && extactinit {
129
+ continue
130
+ }
131
+ if name == "main" && extactmain {
132
132
continue
133
133
}
134
134
You can’t perform that action at this time.
0 commit comments