1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

Replace uses of ioutil

ioutil package was deprecated in Go 1.16, replace all uses with their
respective replacements.

This patch was generated with a combination of `gofmt -r`, `eg`, and
manually (for `ioutil.ReadDir`).
This commit is contained in:
Alberto Bertogli
2022-11-12 20:02:52 +00:00
parent 008367d320
commit 3ebe5c5173
22 changed files with 42 additions and 61 deletions

View File

@@ -9,7 +9,6 @@ import (
"expvar"
"flag"
"fmt"
"io/ioutil"
"math/rand"
"net"
"os"
@@ -112,13 +111,13 @@ func main() {
// The structure matches letsencrypt's, to make it easier for that case.
log.Infof("Loading certificates")
for _, info := range mustReadDir("certs/") {
name := info.Name()
dir := filepath.Join("certs/", name)
if fi, err := os.Stat(dir); err == nil && !fi.IsDir() {
if !info.IsDir() {
// Skip non-directories.
continue
}
name := info.Name()
dir := filepath.Join("certs/", name)
log.Infof(" %s", name)
certPath := filepath.Join(dir, "fullchain.pem")
@@ -291,8 +290,8 @@ func loadDovecot(s *smtpsrv.Server, userdb, client string) {
}
// Read a directory, which must have at least some entries.
func mustReadDir(path string) []os.FileInfo {
dirs, err := ioutil.ReadDir(path)
func mustReadDir(path string) []os.DirEntry {
dirs, err := os.ReadDir(path)
if err != nil {
log.Fatalf("Error reading %q directory: %v", path, err)
}