Skip to content

Commit

Permalink
move err declarations into if statements
Browse files Browse the repository at this point in the history
  • Loading branch information
pseidemann committed Dec 12, 2023
1 parent ec080dc commit 592d3bc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ func main() {
fin.Add(srv)

go func() {
err := srv.ListenAndServe()
if err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down Expand Up @@ -99,8 +98,7 @@ func main() {
fin.Add(srv)

go func() {
err := srv.ListenAndServe()
if err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down Expand Up @@ -141,8 +139,7 @@ func main() {
fin.Add(srv)

go func() {
err := srv.ListenAndServe()
if err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down Expand Up @@ -183,8 +180,7 @@ func main() {
fin.Add(srv)

go func() {
err := srv.ListenAndServe()
if err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down Expand Up @@ -242,16 +238,14 @@ func main() {

go func() {
logrus.Infof("starting public server at %s", srvPub.Addr)
err := srvPub.ListenAndServe()
if err != http.ErrServerClosed {
if err := srvPub.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()

go func() {
logrus.Infof("starting internal server at %s", srvInt.Addr)
err := srvInt.ListenAndServe()
if err != http.ErrServerClosed {
if err := srvInt.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down
3 changes: 1 addition & 2 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ func Example() {
fin.Add(srv)

go func() {
err := srv.ListenAndServe()
if err != http.ErrServerClosed {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
Expand Down
3 changes: 1 addition & 2 deletions finish.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ func (f *Finisher) Wait() {
ctx, cancel := context.WithTimeout(context.Background(), keeper.timeout)
defer cancel()
f.log().Infof("finish: shutting down %s ...", keeper.name)
err := keeper.srv.Shutdown(ctx)
if err != nil {
if err := keeper.srv.Shutdown(ctx); err != nil {
if err == context.DeadlineExceeded {
f.log().Errorf("finish: shutdown timeout for %s", keeper.name)
} else {
Expand Down
3 changes: 1 addition & 2 deletions finish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ func TestOptionError(t *testing.T) {
fin := New()
func() {
defer func() {
err := recover()
if err != errTest {
if err := recover(); err != errTest {
t.Error("expected Add() to panic")
}
}()
Expand Down

0 comments on commit 592d3bc

Please sign in to comment.