Update the Go version in go.mod to 1.18 (#1132)

* Replace functions from `ioutil` with same functions from `io`

This is demanded by staticcheck if we upgrade the go version in go.mod.

* Replace ioutil.ReadDir with os.ReadDir

* Update Go version to 1.18 in go.mod

This requires abandoning use of the `ioutil` module (see parent commits)
to pass `staticcheck`.
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2023-02-26 01:01:04 +03:00
1 parent b02fd42df4
commit 7a7e81e88c
4 files changed
+18 -14

No files matched your search

+7 -8
View File
@@ -1,7 +1,6 @@
package main
import (
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -253,7 +252,7 @@ func matchExec(s string) (matches []string, longest []rune) {
continue
}
files, err := ioutil.ReadDir(p)
files, err := os.ReadDir(p)
if err != nil {
log.Printf("reading path: %s", err)
}
@@ -263,18 +262,18 @@ func matchExec(s string) (matches []string, longest []rune) {
continue
}
f, err = os.Stat(filepath.Join(p, f.Name()))
finfo, err := f.Info()
if err != nil {
log.Printf("getting file information: %s", err)
continue
}
if !f.Mode().IsRegular() || !isExecutable(f) {
if !finfo.Mode().IsRegular() || !isExecutable(finfo) {
continue
}
log.Print(f.Name())
words = append(words, f.Name())
log.Print(finfo.Name())
words = append(words, finfo.Name())
}
}
@@ -307,7 +306,7 @@ func matchFile(s string) (matches []string, longest []rune) {
dir = filepath.Dir(unescape(dir))
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
log.Printf("reading directory: %s", err)
}
@@ -425,7 +424,7 @@ func completeFile(acc []rune) (matches []string, longestAcc []rune) {
log.Printf("getting current directory: %s", err)
}
files, err := ioutil.ReadDir(wd)
files, err := os.ReadDir(wd)
if err != nil {
log.Printf("reading directory: %s", err)
}