Skip to content

Commit 859e36b

Browse files
committed
Reorder :)
1 parent 24a095f commit 859e36b

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

cmd/goreorder/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ var (
3636
defaultOutpout io.Writer = os.Stdout
3737
)
3838

39+
func main() {
40+
if err := buildMainCommand().Execute(); err != nil {
41+
fmt.Println(fmt.Errorf("%v", err))
42+
os.Exit(1)
43+
}
44+
}
45+
3946
type ReorderConfig struct {
4047
FormatToolName string `yaml:"format"`
4148
Write bool `yaml:"write"`
@@ -45,13 +52,6 @@ type ReorderConfig struct {
4552
DefOrder []string `yaml:"order"`
4653
}
4754

48-
func main() {
49-
if err := buildMainCommand().Execute(); err != nil {
50-
fmt.Println(fmt.Errorf("%v", err))
51-
os.Exit(1)
52-
}
53-
}
54-
5555
func processFile(fileOrDirectoryName string, input []byte, config *ReorderConfig) {
5656
if strings.HasSuffix(fileOrDirectoryName, "_test.go") {
5757
log.Println("Skipping test file: " + fileOrDirectoryName)

log/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ var (
1212
logger *l.Logger
1313
)
1414

15+
func init() {
16+
// set the log output to stderr
17+
logger = l.New(os.Stderr, "", l.LstdFlags)
18+
}
19+
1520
func GetLogger() *l.Logger {
1621
return logger
1722
}
@@ -26,8 +31,3 @@ func SetVerbose(v bool) {
2631
logger.SetOutput(writer)
2732
}
2833
}
29-
30-
func init() {
31-
// set the log output to stderr
32-
logger = l.New(os.Stderr, "", l.LstdFlags)
33-
}

ordering/main.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,16 @@ func processConst(
9090
return source
9191
}
9292

93-
func processFunctions(
93+
func processExtractedFunction(
9494
info *ParsedInfo,
9595
functionNames, originalContent, source []string,
9696
removedLines, lineNumberWhereInject *int,
9797
sign string,
98-
extactinit, extactmain bool,
98+
funcname string,
9999
) []string {
100100
for _, name := range functionNames {
101101

102-
if name == "init" && extactinit {
103-
continue
104-
}
105-
if name == "main" && extactmain {
102+
if funcname != name {
106103
continue
107104
}
108105

@@ -119,16 +116,19 @@ func processFunctions(
119116
return source
120117
}
121118

122-
func processExtractedFunction(
119+
func processFunctions(
123120
info *ParsedInfo,
124121
functionNames, originalContent, source []string,
125122
removedLines, lineNumberWhereInject *int,
126123
sign string,
127-
funcname string,
124+
extactinit, extactmain bool,
128125
) []string {
129126
for _, name := range functionNames {
130127

131-
if funcname != name {
128+
if name == "init" && extactinit {
129+
continue
130+
}
131+
if name == "main" && extactmain {
132132
continue
133133
}
134134

0 commit comments

Comments
 (0)