diff options
author | Oleksandr Redko <oleksandr.red+github@gmail.com> | 2023-02-19 00:43:26 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-01 16:28:43 +0100 |
commit | d453c12742e992d672fcf3e61b7a5ed35391c4b0 (patch) | |
tree | 1299a1f5a44bda1cf6449a8257f393350b2cc012 /commands/import_jekyll.go | |
parent | 97b010f521e592b5fc29daace225476b64543643 (diff) |
Replace deprecated ioutil with io and os
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
Diffstat (limited to 'commands/import_jekyll.go')
-rw-r--r-- | commands/import_jekyll.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/commands/import_jekyll.go b/commands/import_jekyll.go index 91d5c69fe..93991121d 100644 --- a/commands/import_jekyll.go +++ b/commands/import_jekyll.go @@ -17,7 +17,7 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "regexp" @@ -164,7 +164,7 @@ func (i *importCmd) importFromJekyll(cmd *cobra.Command, args []string) error { func (i *importCmd) getJekyllDirInfo(fs afero.Fs, jekyllRoot string) (map[string]bool, bool) { postDirs := make(map[string]bool) hasAnyPost := false - if entries, err := ioutil.ReadDir(jekyllRoot); err == nil { + if entries, err := os.ReadDir(jekyllRoot); err == nil { for _, entry := range entries { if entry.IsDir() { subDir := filepath.Join(jekyllRoot, entry.Name()) @@ -186,7 +186,7 @@ func (i *importCmd) retrieveJekyllPostDir(fs afero.Fs, dir string) (bool, bool) return true, !isEmpty } - if entries, err := ioutil.ReadDir(dir); err == nil { + if entries, err := os.ReadDir(dir); err == nil { for _, entry := range entries { if entry.IsDir() { subDir := filepath.Join(dir, entry.Name()) @@ -247,7 +247,7 @@ func (i *importCmd) loadJekyllConfig(fs afero.Fs, jekyllRoot string) map[string] defer f.Close() - b, err := ioutil.ReadAll(f) + b, err := io.ReadAll(f) if err != nil { return nil } @@ -310,7 +310,7 @@ func (i *importCmd) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyllPos if err != nil { return err } - entries, err := ioutil.ReadDir(jekyllRoot) + entries, err := os.ReadDir(jekyllRoot) if err != nil { return err } @@ -386,7 +386,7 @@ func convertJekyllPost(path, relPath, targetDir string, draft bool) error { targetParentDir := filepath.Dir(targetFile) os.MkdirAll(targetParentDir, 0777) - contentBytes, err := ioutil.ReadFile(path) + contentBytes, err := os.ReadFile(path) if err != nil { jww.ERROR.Println("Read file error:", path) return err |