aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddy.go
diff options
context:
space:
mode:
authorKallyDev <[email protected]>2021-09-30 01:17:48 +0800
committerGitHub <[email protected]>2021-09-29 11:17:48 -0600
commitc48fadc4a7655008d13076c7f757c36368e2ca13 (patch)
tree3fe2837e02e9b664dd5b86afbe42494ac20997f8 /caddy.go
parent059fc32f002d00e980b438b3edbdf7b8bcdf9a90 (diff)
downloadcaddy-c48fadc4a7655008d13076c7f757c36368e2ca13.tar.gz
caddy-c48fadc4a7655008d13076c7f757c36368e2ca13.zip
Move from deprecated ioutil to os and io packages (#4364)
Diffstat (limited to 'caddy.go')
-rw-r--r--caddy.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/caddy.go b/caddy.go
index ba025b18a..a7e99c111 100644
--- a/caddy.go
+++ b/caddy.go
@@ -20,7 +20,6 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
"log"
"net/http"
"os"
@@ -300,7 +299,7 @@ func unsyncedDecodeAndRun(cfgJSON []byte, allowPersist bool) error {
zap.String("dir", dir),
zap.Error(err))
} else {
- err := ioutil.WriteFile(ConfigAutosavePath, cfgJSON, 0600)
+ err := os.WriteFile(ConfigAutosavePath, cfgJSON, 0600)
if err == nil {
Log().Info("autosaved config (load with --resume flag)", zap.String("file", ConfigAutosavePath))
} else {
@@ -700,13 +699,13 @@ func ParseDuration(s string) (time.Duration, error) {
// have its own unique ID.
func InstanceID() (uuid.UUID, error) {
uuidFilePath := filepath.Join(AppDataDir(), "instance.uuid")
- uuidFileBytes, err := ioutil.ReadFile(uuidFilePath)
+ uuidFileBytes, err := os.ReadFile(uuidFilePath)
if os.IsNotExist(err) {
uuid, err := uuid.NewRandom()
if err != nil {
return uuid, err
}
- err = ioutil.WriteFile(uuidFilePath, []byte(uuid.String()), 0600)
+ err = os.WriteFile(uuidFilePath, []byte(uuid.String()), 0600)
return uuid, err
} else if err != nil {
return [16]byte{}, err