Use errors.Is to compare ErrServerClosed in main

This commit is contained in:
jordi fita mas 2024-01-19 19:44:11 +01:00
parent 7e377f550c
commit 22ee6343e2
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"errors"
"log" "log"
"net/http" "net/http"
"os" "os"
@ -29,7 +30,7 @@ func main() {
go func() { go func() {
log.Printf("INFO - listening on %s\n", srv.Addr) log.Printf("INFO - listening on %s\n", srv.Addr)
if err := srv.ListenAndServe(); err != http.ErrServerClosed { if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("http server: %v", err) log.Fatalf("http server: %v", err)
} }
}() }()