Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation of package ioutil #45

Merged
merged 4 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Deprecation of package ioutil
  • Loading branch information
SenexCrenshaw committed Sep 6, 2022
commit 4a16a7e8907fa5d582b333f24dce00899a1a175e
3 changes: 1 addition & 2 deletions src/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
b64 "encoding/base64"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -32,7 +31,7 @@ func xTeVeAutoBackup() (err error) {
}

// Delete Old Backups
files, err := ioutil.ReadDir(System.Folder.Backup)
files, err := os.ReadDir(System.Folder.Backup)

if err == nil {

Expand Down
3 changes: 1 addition & 2 deletions src/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -821,7 +820,7 @@ func connectToStreamingServer(streamID int, playlistID string) {

// M3U8 Playlist
case "application/x-mpegurl", "application/vnd.apple.mpegurl", "audio/mpegurl", "audio/x-mpegurl":
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
ShowError(err, 0)
addErrorToStream(err)
Expand Down
3 changes: 1 addition & 2 deletions src/html-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -127,7 +126,7 @@ func getLocalPath(filename string) string {

func writeStringToFile(filename, content string) error {

err := ioutil.WriteFile(getPlatformFile(filename), []byte(content), 0644)
err := os.WriteFile(getPlatformFile(filename), []byte(content), 0644)
if err != nil {
checkErr(err)
return err
Expand Down
4 changes: 2 additions & 2 deletions src/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package src

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -314,7 +314,7 @@ func downloadFileFromServer(providerURL string) (filename string, body []byte, e

}

body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
return
}
Expand Down
15 changes: 7 additions & 8 deletions src/toolchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"io/ioutil"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -157,7 +157,7 @@ func checkFilePermission(dir string) (err error) {

var filename = dir + "permission.test"

err = ioutil.WriteFile(filename, []byte(""), 0644)
err = os.WriteFile(filename, []byte(""), 0644)
if err == nil {
err = os.RemoveAll(filename)
}
Expand Down Expand Up @@ -247,7 +247,6 @@ func searchFileInOS(file string) (path string) {
return
}

//
func removeChildItems(dir string) error {

files, err := filepath.Glob(filepath.Join(dir, "*"))
Expand Down Expand Up @@ -302,7 +301,7 @@ func saveMapToJSONFile(file string, tmpMap interface{}) error {
return err
}

err = ioutil.WriteFile(filename, []byte(jsonString), 0644)
err = os.WriteFile(filename, []byte(jsonString), 0644)
if err != nil {
return err
}
Expand All @@ -318,7 +317,7 @@ func loadJSONFileToMap(file string) (tmpMap map[string]interface{}, err error) {
}
defer f.Close()

content, err := ioutil.ReadAll(f)
content, err := io.ReadAll(f)

if err == nil {
err = json.Unmarshal([]byte(content), &tmpMap)
Expand All @@ -338,7 +337,7 @@ func readByteFromFile(file string) (content []byte, err error) {
}
defer f.Close()

content, err = ioutil.ReadAll(f)
content, err = io.ReadAll(f)
f.Close()

return
Expand All @@ -347,7 +346,7 @@ func readByteFromFile(file string) (content []byte, err error) {
func writeByteToFile(file string, data []byte) (err error) {

var filename = getPlatformFile(file)
err = ioutil.WriteFile(filename, data, 0644)
err = os.WriteFile(filename, data, 0644)

return
}
Expand All @@ -362,7 +361,7 @@ func readStringFromFile(file string) (str string, err error) {
return
}

content, err = ioutil.ReadFile(filename)
content, err = os.ReadFile(filename)
if err != nil {
ShowError(err, 0)
return
Expand Down
8 changes: 4 additions & 4 deletions src/tvlogos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package src
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -39,7 +39,7 @@ func downloadLogoJSON() {
logoJsonExists := err == nil

if logoJsonExists && time.Now().Before(info.ModTime().Add(time.Hour*168)) {
content, err := ioutil.ReadFile(System.File.TVLogos)
content, err := os.ReadFile(System.File.TVLogos)
if err != nil {
ShowError(err, 0)
}
Expand All @@ -59,7 +59,7 @@ func downloadLogoJSON() {
return
}

b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
defer resp.Body.Close()
if err != nil {
return
Expand Down Expand Up @@ -100,7 +100,7 @@ func downloadLogoJSON() {
})

file, _ := json.MarshalIndent(Data.Logos, "", " ")
_ = ioutil.WriteFile(System.File.TVLogos, file, 0644)
_ = os.WriteFile(System.File.TVLogos, file, 0644)

}
}
4 changes: 2 additions & 2 deletions src/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"

up2date "xteve/src/internal/up2date/client"
Expand Down Expand Up @@ -58,7 +58,7 @@ func BinaryUpdate() (err error) {
return err
}

body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)

err = json.Unmarshal(body, &git)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions src/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"regexp"
Expand Down Expand Up @@ -1101,7 +1101,7 @@ func API(w http.ResponseWriter, r *http.Request) {
return
}

b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
defer r.Body.Close()
if err != nil {
httpStatusError(w, r, 400)
Expand Down
4 changes: 2 additions & 2 deletions src/xepg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
"runtime"
Expand Down Expand Up @@ -701,7 +701,7 @@ func createXMLTVFile() (err error) {
Data.Cache.ImagesURLS = []string{}
Data.Cache.ImagesCache = []string{}

files, err := ioutil.ReadDir(System.Folder.ImagesCache)
files, err := os.ReadDir(System.Folder.ImagesCache)
if err == nil {

for _, file := range files {
Expand Down