Use new methods in the io and os packages instead of ioutil ones

ioutil is deprecated in Go 1.16 and SFTPGo is an application, not
a library, we have no reason to keep compatibility with old Go
versions.

Go 1.16 fix some cifs related issues too.
This commit is contained in:
Nicola Murino
2021-02-25 21:53:04 +01:00
parent 4b2edff6dd
commit ca3e15578e
37 changed files with 211 additions and 232 deletions

View File

@@ -1,7 +1,6 @@
package telemetry
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
@@ -65,9 +64,9 @@ func TestInitialization(t *testing.T) {
certPath := filepath.Join(os.TempDir(), "test.crt")
keyPath := filepath.Join(os.TempDir(), "test.key")
err = ioutil.WriteFile(certPath, []byte(httpsCert), os.ModePerm)
err = os.WriteFile(certPath, []byte(httpsCert), os.ModePerm)
require.NoError(t, err)
err = ioutil.WriteFile(keyPath, []byte(httpsKey), os.ModePerm)
err = os.WriteFile(keyPath, []byte(httpsKey), os.ModePerm)
require.NoError(t, err)
c.CertificateFile = certPath
@@ -104,7 +103,7 @@ func TestShouldBind(t *testing.T) {
func TestRouter(t *testing.T) {
authUserFile := filepath.Join(os.TempDir(), "http_users.txt")
authUserData := []byte("test1:$2y$05$bcHSED7aO1cfLto6ZdDBOOKzlwftslVhtpIkRhAtSa4GuLmk5mola\n")
err := ioutil.WriteFile(authUserFile, authUserData, os.ModePerm)
err := os.WriteFile(authUserFile, authUserData, os.ModePerm)
require.NoError(t, err)
httpAuth, err = common.NewBasicAuthProvider(authUserFile)