chore: switch complex deprecated ioutil.ReadDir to 1.17_ replacement
complex, because it required checking the changed result type for suitability.
+// -*- fill-column: 90 -*-
package helpers
import (
- "io/ioutil"
"os"
"path"
@@ -10,18 +10,17 @@ import (
)
func Tar(dir string) (string, string, error) {
- files, err := ioutil.ReadDir(dir)
+ files, err := os.ReadDir(dir)
if err != nil {
return "", "", errors.Wrap(err, "cannot read the apps source files")
}
sources := []string{}
for _, f := range files {
- // The FileInfo entries returned by ReadDir provide
- // only the base name of the file or directory they
- // are for. We have to add back the path of the
- // application directory to get the proper paths to
- // the files and directories to assemble in the
- // tarball.
+ // The os.DirEntry structures returned by ReadDir() provide only the base
+ // name of the file or directory they are for. We have to add back the
+ // path of the application directory to get the proper paths to the files
+ // and directories to assemble in the tarball.
+
// Ignore git config files in the app sources.
if f.Name() == ".git" || f.Name() == ".gitignore" || f.Name() == ".gitmodules" || f.Name() == ".gitconfig" || f.Name() == ".git-credentials" {
continue
