diff options
author | Mohammed Al Sahaf <[email protected]> | 2024-01-02 08:48:55 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-01-02 08:48:55 +0300 |
commit | 787f6b257f3ee34431e4f5a9aa33a5399096a78c (patch) | |
tree | 207ea430559b5cb0d6c238bb96207a0466effcea /cmd | |
parent | b568a10dd4feedd5539b181e26a5bbafebd4f984 (diff) | |
download | caddy-787f6b257f3ee34431e4f5a9aa33a5399096a78c.tar.gz caddy-787f6b257f3ee34431e4f5a9aa33a5399096a78c.zip |
chore: check against errors of `io/fs` instead of `os` (#6011)
* chore: replace `os.ErrNotExist` with `fs.ErrNotExist`
* check against permission error from `io/fs` package
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commandfuncs.go | 2 | ||||
-rw-r--r-- | cmd/main.go | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index b0c576a3d..746cf3da6 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -190,7 +190,7 @@ func cmdRun(fl Flags) (int, error) { var config []byte if resumeFlag { config, err = os.ReadFile(caddy.ConfigAutosavePath) - if os.IsNotExist(err) { + if errors.Is(err, fs.ErrNotExist) { // not a bad error; just can't resume if autosave file doesn't exist caddy.Log().Info("no autosave file exists", zap.String("autosave_file", caddy.ConfigAutosavePath)) resumeFlag = false diff --git a/cmd/main.go b/cmd/main.go index fa15c0874..73d70f04d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -21,6 +21,7 @@ import ( "flag" "fmt" "io" + "io/fs" "log" "net" "os" @@ -128,7 +129,7 @@ func loadConfigWithLogger(logger *zap.Logger, configFile, adapterName string) ([ cfgAdapter = caddyconfig.GetAdapter("caddyfile") if cfgAdapter != nil { config, err = os.ReadFile("Caddyfile") - if os.IsNotExist(err) { + if errors.Is(err, fs.ErrNotExist) { // okay, no default Caddyfile; pretend like this never happened cfgAdapter = nil } else if err != nil { |