Replace uses of os.IsExist and os.IsNotExist with errors.Is.

The former don't properly unwrap errors.
This commit is contained in:
Juliusz Chroboczek
2024-04-14 13:33:52 +02:00
parent 68887f13d5
commit 3409f5a27f
10 changed files with 21 additions and 19 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -170,7 +171,7 @@ func apiGroupHandler(w http.ResponseWriter, r *http.Request, pth string) {
return
} else if r.Method == "PUT" {
etag, err := group.GetDescriptionTag(g)
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
err = nil
etag = ""
} else if err != nil {
@@ -299,7 +300,7 @@ func usersHandler(w http.ResponseWriter, r *http.Request, g, pth string) {
return
} else if r.Method == "PUT" {
etag, err := group.GetUserTag(g, username)
if os.IsNotExist(err) {
if errors.Is(err, os.ErrNotExist) {
etag = ""
err = nil
} else if err != nil {