Skip to content

Commit

Permalink
Merge pull request #6686 from mook-as/go/windows-noent
Browse files Browse the repository at this point in the history
golang: prefer `errors.Is(..., ErrNotExist)` over `errors.Is(..., ENOENT)`
  • Loading branch information
Nino-K authored Apr 5, 2024
2 parents fa85b20 + 50bfdf9 commit 375ae3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/go/docker-credential-none/dcnone/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"strings"
"syscall"

dockerconfig "github.com/docker/cli/cli/config"
"github.com/docker/docker-credential-helpers/credentials"
Expand All @@ -19,7 +19,7 @@ func getParsedConfig() (dockerConfigType, error) {
dockerConfig := make(dockerConfigType)
contents, err := os.ReadFile(configFile)
if err != nil {
if errors.Is(err, syscall.ENOENT) {
if errors.Is(err, fs.ErrNotExist) {
// Time to create a new config (or return no data)
return dockerConfig, nil
}
Expand Down
8 changes: 4 additions & 4 deletions src/go/rdctl/pkg/factoryreset/delete_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strings"
"syscall"

dockerconfig "github.com/docker/docker/cli/config"
"github.com/rancher-sandbox/rancher-desktop/src/go/rdctl/pkg/directories"
Expand Down Expand Up @@ -139,7 +139,7 @@ func removeDockerCliPlugins(altAppHomePath string) error {
cliPluginsDir := path.Join(dockerconfig.Dir(), "cli-plugins")
entries, err := os.ReadDir(cliPluginsDir)
if err != nil {
if errors.Is(err, syscall.ENOENT) {
if errors.Is(err, fs.ErrNotExist) {
// Nothing left to do here, since there is no cli-plugins dir
return nil
}
Expand Down Expand Up @@ -172,7 +172,7 @@ func removePathManagement(dotFiles []string) error {
for _, dotFile := range dotFiles {
byteContents, err := os.ReadFile(dotFile)
if err != nil {
if !errors.Is(err, syscall.ENOENT) {
if !errors.Is(err, fs.ErrNotExist) {
logrus.Errorf("Error trying to read %s: %s\n", dotFile, err)
}
continue
Expand Down Expand Up @@ -255,7 +255,7 @@ func clearDockerContext() error {
dockerConfigContents := make(dockerConfigType)
contents, err := os.ReadFile(configFilePath)
if err != nil {
if os.IsNotExist(err) {
if errors.Is(err, fs.ErrNotExist) {
// Nothing left to do here, since the file doesn't exist
return nil
}
Expand Down

0 comments on commit 375ae3f

Please sign in to comment.