Skip to content

Commit a7e0694

Browse files
committed
Slightly simplified usage of os.Exit(..)
Signed-off-by: Cristian Maglie <[email protected]>
1 parent fa317a6 commit a7e0694

File tree

1 file changed

+3
-9
lines changed
  • src/arduino.cc/arduino-builder

1 file changed

+3
-9
lines changed

src/arduino.cc/arduino-builder/main.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func main() {
167167
fmt.Println("See https://www.arduino.cc/ and https://github.com/arduino/arduino-builder/graphs/contributors")
168168
fmt.Println("This is free software; see the source for copying conditions. There is NO")
169169
fmt.Println("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.")
170-
defer os.Exit(0)
171170
return
172171
}
173172

@@ -249,8 +248,7 @@ func main() {
249248
_, err := os.Stat(buildPath)
250249
if err != nil {
251250
fmt.Fprintln(os.Stderr, err)
252-
defer os.Exit(1)
253-
return
251+
os.Exit(1)
254252
}
255253

256254
err = utils.EnsureFolderExists(buildPath)
@@ -314,13 +312,11 @@ func main() {
314312
if flag.NArg() == 0 {
315313
fmt.Fprintln(os.Stderr, "Last parameter must be the sketch to compile")
316314
flag.Usage()
317-
defer os.Exit(1)
318-
return
315+
os.Exit(1)
319316
}
320317
err = builder.RunBuilder(context, ctx)
321318
}
322319

323-
exitCode := 0
324320
if err != nil {
325321
err = i18n.WrapError(err)
326322

@@ -330,10 +326,8 @@ func main() {
330326
fmt.Fprintln(os.Stderr, err.(*errors.Error).ErrorStack())
331327
}
332328

333-
exitCode = toExitCode(err)
329+
os.Exit(toExitCode(err))
334330
}
335-
336-
defer os.Exit(exitCode)
337331
}
338332

339333
func setContextSliceKeyOrLoadItFromOptions(context map[string]interface{}, cliFlag []string, buildOptions map[string]string, contextKey string, paramName string, mandatory bool) (error, bool) {

0 commit comments

Comments
 (0)