diff --git a/cmd/init.go b/cmd/init.go index f63b621..7af6f49 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -4,7 +4,6 @@ import ( "bufio" "encoding/json" "fmt" - "io/ioutil" "os" "path/filepath" "sort" @@ -134,7 +133,7 @@ var initCmd = &cobra.Command{ _, err = os.Stat(indexFilePath) if os.IsNotExist(err) { // Create file - err = ioutil.WriteFile(indexFilePath, []byte{}, 0644) + err = os.WriteFile(indexFilePath, []byte{}, 0644) if err != nil { fmt.Printf("Error creating index file: %s\n", err) os.Exit(1) diff --git a/core/download.go b/core/download.go index b850dcb..86d040e 100644 --- a/core/download.go +++ b/core/download.go @@ -6,7 +6,6 @@ import ( "fmt" "golang.org/x/exp/slices" "io" - "io/ioutil" "net/http" "os" "path/filepath" @@ -108,7 +107,7 @@ func (d *downloadSessionInternal) SaveIndex() error { if err != nil { return fmt.Errorf("failed to serialise index: %w", err) } - err = ioutil.WriteFile(filepath.Join(d.cacheFolder, "index.json"), data, 0644) + err = os.WriteFile(filepath.Join(d.cacheFolder, "index.json"), data, 0644) if err != nil { return fmt.Errorf("failed to write index: %w", err) } @@ -146,7 +145,7 @@ func reuseExistingFile(cacheHandle *CacheIndexHandle, hashesToObtain []string, m func downloadNewFile(task *downloadTask, cacheFolder string, hashesToObtain []string, index *CacheIndex) (CompletedDownload, error) { // Create temp file to download to - tempFile, err := ioutil.TempFile(filepath.Join(cacheFolder, "temp"), "download-tmp") + tempFile, err := os.CreateTemp(filepath.Join(cacheFolder, "temp"), "download-tmp") if err != nil { return CompletedDownload{}, fmt.Errorf("failed to create temporary file for download: %w", err) } @@ -551,7 +550,7 @@ func CreateDownloadSession(mods []*Mod, hashesToObtain []string) (DownloadSessio if err != nil { return nil, fmt.Errorf("failed to create cache temp directory: %w", err) } - cacheIndexData, err := ioutil.ReadFile(filepath.Join(cachePath, "index.json")) + cacheIndexData, err := os.ReadFile(filepath.Join(cachePath, "index.json")) if err != nil { if !os.IsNotExist(err) { return nil, fmt.Errorf("failed to read cache index file: %w", err) diff --git a/core/index.go b/core/index.go index 77dd49d..347107e 100644 --- a/core/index.go +++ b/core/index.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path/filepath" "sort" @@ -183,7 +182,7 @@ var ignoreDefaults = []string{ } func readGitignore(path string) (*gitignore.GitIgnore, bool) { - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { // TODO: check for read errors (and present them) return gitignore.CompileIgnoreLines(ignoreDefaults...), false diff --git a/curseforge/import.go b/curseforge/import.go index 8d60cc5..7081d3f 100644 --- a/curseforge/import.go +++ b/curseforge/import.go @@ -8,7 +8,6 @@ import ( "fmt" "github.com/packwiz/packwiz/curseforge/packinterop" "io" - "io/ioutil" "os" "path/filepath" "runtime" @@ -97,7 +96,7 @@ var importCmd = &cobra.Command{ // Check if file is a zip if string(header) == "PK" { // Read the whole file (as bufio doesn't work for zips) - zipData, err := ioutil.ReadAll(buf) + zipData, err := io.ReadAll(buf) if err != nil { fmt.Printf("Error reading file: %s\n", err) os.Exit(1) @@ -142,7 +141,7 @@ var importCmd = &cobra.Command{ _, err = os.Stat(indexFilePath) if os.IsNotExist(err) { // Create file - err = ioutil.WriteFile(indexFilePath, []byte{}, 0644) + err = os.WriteFile(indexFilePath, []byte{}, 0644) if err != nil { fmt.Printf("Error creating index file: %s\n", err) os.Exit(1) diff --git a/curseforge/packinterop/disk.go b/curseforge/packinterop/disk.go index f302bd1..dabf9d7 100644 --- a/curseforge/packinterop/disk.go +++ b/curseforge/packinterop/disk.go @@ -3,7 +3,6 @@ package packinterop import ( "bufio" "io" - "io/ioutil" "os" "path/filepath" ) @@ -68,7 +67,7 @@ func (s diskPackSource) GetFileList() ([]ImportPackFile, error) { } func (s diskPackSource) GetPackFile() ImportPackFile { - rc := ioutil.NopCloser(s.MetaSource) + rc := io.NopCloser(s.MetaSource) return readerFile{s.MetaName, &rc} } diff --git a/curseforge/packinterop/translation.go b/curseforge/packinterop/translation.go index f6e3091..898158d 100644 --- a/curseforge/packinterop/translation.go +++ b/curseforge/packinterop/translation.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/packwiz/packwiz/core" "io" - "io/ioutil" "os" ) @@ -20,7 +19,7 @@ func ReadMetadata(s ImportPackSource) ImportPackMetadata { } // Read the whole file (as we are going to parse it multiple times) - fileData, err := ioutil.ReadAll(rdr) + fileData, err := io.ReadAll(rdr) if err != nil { fmt.Printf("Error reading file: %s\n", err) os.Exit(1)