Re-use err variable, instead of creating new error vars

This commit is contained in:
Matt Baer 2022-12-26 13:17:56 -05:00
parent baaf0580f5
commit 7a84d27dca

18
app.go
View file

@ -513,9 +513,9 @@ requests. We recommend supplying a valid host name.`)
// old sockets will remain after server closes; // old sockets will remain after server closes;
// we need to delete them in order to open new ones // we need to delete them in order to open new ones
removeSocketErr := os.Remove(bindAddress) err = os.Remove(bindAddress)
if removeSocketErr != nil && !os.IsNotExist(removeSocketErr) { if err != nil && !os.IsNotExist(err) {
log.Error("%s already exists but could not be removed: %v", bindAddress, removeSocketErr) log.Error("%s already exists but could not be removed: %v", bindAddress, err)
os.Exit(1) os.Exit(1)
} }
} else { } else {
@ -526,16 +526,16 @@ requests. We recommend supplying a valid host name.`)
log.Info("Serving on %s://%s", protocol, bindAddress) log.Info("Serving on %s://%s", protocol, bindAddress)
log.Info("---") log.Info("---")
listener, listenErr := net.Listen(network, bindAddress) listener, err := net.Listen(network, bindAddress)
if listenErr != nil { if err != nil {
log.Error("Could not bind to address: %v", listenErr) log.Error("Could not bind to address: %v", err)
os.Exit(1) os.Exit(1)
} }
if network == "unix" { if network == "unix" {
chmodSocketErr := os.Chmod(bindAddress, 0o666) err = os.Chmod(bindAddress, 0o666)
if chmodSocketErr != nil { if err != nil {
log.Error("Could not update socket permissions: %v", chmodSocketErr) log.Error("Could not update socket permissions: %v", err)
os.Exit(1) os.Exit(1)
} }
} }