Closed
Description
Go 1.16 will introduce a new exported net.ErrClosed
(see this issue for context) error allowing Caddy to properly check for this error instead of using the substring matching hack.
Current code:
Lines 115 to 123 in 385adf5
Proposed patch once Caddy starts using go 1.16:
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 772fe012..36c686c5 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -19,6 +19,7 @@ import (
"context"
"crypto/rand"
"encoding/json"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -116,7 +117,7 @@ func cmdStart(fl Flags) (int, error) {
for {
conn, err := ln.Accept()
if err != nil {
- if !strings.Contains(err.Error(), "use of closed network connection") {
+ if !errors.Is(err, net.ErrClosed) {
log.Println(err)
}
break
Please, let me know what do you think about it and, if you would prefer me to open the PR now or if I should wait for 1.16 to be released. Also, please feel free to close this issue if you don't think we need this code change.
Best,
Miguel
Metadata
Metadata
Assignees
Labels
No labels