Skip to content

Commit

Permalink
Close the server and check for the ErrServerClosed error
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgelbg committed Jul 9, 2020
1 parent a4d911c commit f62adb2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ func main() {
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
}
defer server.Close()
server.Addr = ":8080"

logger.Sugar().Infow("Server is running",
"port", 8080,
)

if err := server.ListenAndServe(); err != nil {
if err := server.ListenAndServe(); err != http.ErrServerClosed {
logger.Error("Could not start HTTP server.",
zap.Error(err),
)
Expand Down

0 comments on commit f62adb2

Please sign in to comment.