From 436c73c39bd5fbfe666255070301d1638a1d8999 Mon Sep 17 00:00:00 2001
From: Gavin Inglis <43075615+ginglis13@users.noreply.github.com>
Date: Fri, 13 Oct 2023 17:52:59 -0400
Subject: [PATCH] deps: remove ioutil package (#583)

ioutil has been deprecated since Go 1.16:
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <ginglis05@gmail.com>
---
 server/clamav.go         | 4 ++--
 server/storage/gdrive.go | 7 +++----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/server/clamav.go b/server/clamav.go
index b28fc478..507f3141 100644
--- a/server/clamav.go
+++ b/server/clamav.go
@@ -30,8 +30,8 @@ import (
 	"errors"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"net/http"
+	"os"
 	"time"
 
 	"github.com/dutchcoders/go-clamd"
@@ -50,7 +50,7 @@ func (s *Server) scanHandler(w http.ResponseWriter, r *http.Request) {
 
 	s.logger.Printf("Scanning %s %d %s", filename, contentLength, contentType)
 
-	file, err := ioutil.TempFile(s.tempPath, "clamav-")
+	file, err := os.CreateTemp(s.tempPath, "clamav-")
 	defer s.cleanTmpFile(file)
 	if err != nil {
 		s.logger.Printf("%s", err.Error())
diff --git a/server/storage/gdrive.go b/server/storage/gdrive.go
index b59df27a..d035f54b 100644
--- a/server/storage/gdrive.go
+++ b/server/storage/gdrive.go
@@ -5,7 +5,6 @@ import (
 	"encoding/json"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"log"
 	"net/http"
 	"os"
@@ -37,7 +36,7 @@ const gDriveDirectoryMimeType = "application/vnd.google-apps.folder"
 // NewGDriveStorage is the factory for GDrive
 func NewGDriveStorage(ctx context.Context, clientJSONFilepath string, localConfigPath string, basedir string, chunkSize int, logger *log.Logger) (*GDrive, error) {
 
-	b, err := ioutil.ReadFile(clientJSONFilepath)
+	b, err := os.ReadFile(clientJSONFilepath)
 	if err != nil {
 		return nil, err
 	}
@@ -67,7 +66,7 @@ func NewGDriveStorage(ctx context.Context, clientJSONFilepath string, localConfi
 func (s *GDrive) setupRoot() error {
 	rootFileConfig := filepath.Join(s.localConfigPath, gDriveRootConfigFile)
 
-	rootID, err := ioutil.ReadFile(rootFileConfig)
+	rootID, err := os.ReadFile(rootFileConfig)
 	if err != nil && !os.IsNotExist(err) {
 		return err
 	}
@@ -88,7 +87,7 @@ func (s *GDrive) setupRoot() error {
 	}
 
 	s.rootID = di.Id
-	err = ioutil.WriteFile(rootFileConfig, []byte(s.rootID), os.FileMode(0600))
+	err = os.WriteFile(rootFileConfig, []byte(s.rootID), os.FileMode(0600))
 	if err != nil {
 		return err
 	}
-- 
GitLab