diff --git a/build/css.go b/build/css.go index ca31c2c..c58a581 100644 --- a/build/css.go +++ b/build/css.go @@ -1,7 +1,6 @@ package build import ( - "io/ioutil" "math/rand" "os" "strings" @@ -10,7 +9,7 @@ import ( // Gets file paths from directory recursively. func getFilePathsRecursively(dir string) ([]string, error) { var paths []string - files, err := ioutil.ReadDir(dir) + files, err := os.ReadDir(dir) if err != nil { return nil, err } @@ -32,7 +31,7 @@ func getFilePathsRecursively(dir string) ([]string, error) { // Returns all css files paths in ../static/styles folder. func getCssFilesPaths() []string { var paths []string - files, err := ioutil.ReadDir("static/styles") + files, err := os.ReadDir("static/styles") if err != nil { panic(err) } @@ -99,7 +98,7 @@ func RenameCss() { } for _, htmlTemplatePath := range htmlTemplatePaths { - htmlTemplate, err := ioutil.ReadFile(htmlTemplatePath) + htmlTemplate, err := os.ReadFile(htmlTemplatePath) if err != nil { panic(err) } @@ -108,7 +107,7 @@ func RenameCss() { htmlTemplate = []byte(strings.Replace(string(htmlTemplate), origPath, newPath, -1)) } // write html template to file - err = ioutil.WriteFile(htmlTemplatePath, htmlTemplate, 0644) + err = os.WriteFile(htmlTemplatePath, htmlTemplate, 0644) if err != nil { panic(err) } diff --git a/files/get_files_in_folder.go b/files/get_files_in_folder.go index 449f31e..8783cd1 100644 --- a/files/get_files_in_folder.go +++ b/files/get_files_in_folder.go @@ -1,7 +1,6 @@ package files import ( - "io/ioutil" "log" "os" "path" @@ -15,7 +14,7 @@ func GetFullFilePathsInFolder(folder string) []string { } fullFolderPath := path.Join(currentPath, folder) - files, err := ioutil.ReadDir(fullFolderPath) + files, err := os.ReadDir(fullFolderPath) if err != nil { log.Fatal(err) } @@ -31,7 +30,7 @@ func GetFullFilePathsInFolder(folder string) []string { // Reads file contents by full path and returns string func ReadFileText(fullFilePath string) string { - file, err := ioutil.ReadFile(fullFilePath) + file, err := os.ReadFile(fullFilePath) if err != nil { log.Fatal(err) } diff --git a/gateway/connect.go b/gateway/connect.go index 2b859b2..87b5fc6 100644 --- a/gateway/connect.go +++ b/gateway/connect.go @@ -3,7 +3,7 @@ package gateway import ( "bytes" "encoding/json" - "io/ioutil" + "io" "log" "net/http" @@ -29,8 +29,9 @@ func Connect() { if err != nil { log.Panicln(err) } + defer resp.Body.Close() //We Read the response body on the line below. - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { log.Panicln(err) }