mirror of
https://github.com/fatedier/frp.git
synced 2025-07-27 07:35:07 +00:00
refactor: move from io/ioutil to io and os package (#2592)
This commit is contained in:
@@ -3,7 +3,6 @@ package framework
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -90,7 +89,7 @@ func (f *Framework) BeforeEach() {
|
||||
|
||||
f.cleanupHandle = AddCleanupAction(f.AfterEach)
|
||||
|
||||
dir, err := ioutil.TempDir(os.TempDir(), "frp-e2e-test-*")
|
||||
dir, err := os.MkdirTemp(os.TempDir(), "frp-e2e-test-*")
|
||||
ExpectNoError(err)
|
||||
f.TempDirectory = dir
|
||||
|
||||
@@ -260,7 +259,7 @@ func (f *Framework) SetEnvs(envs []string) {
|
||||
|
||||
func (f *Framework) WriteTempFile(name string, content string) string {
|
||||
filePath := filepath.Join(f.TempDirectory, name)
|
||||
err := ioutil.WriteFile(filePath, []byte(content), 0766)
|
||||
err := os.WriteFile(filePath, []byte(content), 0766)
|
||||
ExpectNoError(err)
|
||||
return filePath
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package framework
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -30,7 +30,7 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
|
||||
|
||||
for i := range serverTemplates {
|
||||
path := filepath.Join(f.TempDirectory, fmt.Sprintf("frp-e2e-server-%d", i))
|
||||
err = ioutil.WriteFile(path, []byte(outs[i]), 0666)
|
||||
err = os.WriteFile(path, []byte(outs[i]), 0666)
|
||||
ExpectNoError(err)
|
||||
flog.Trace("[%s] %s", path, outs[i])
|
||||
|
||||
@@ -45,7 +45,7 @@ func (f *Framework) RunProcesses(serverTemplates []string, clientTemplates []str
|
||||
for i := range clientTemplates {
|
||||
index := i + len(serverTemplates)
|
||||
path := filepath.Join(f.TempDirectory, fmt.Sprintf("frp-e2e-client-%d", i))
|
||||
err = ioutil.WriteFile(path, []byte(outs[index]), 0666)
|
||||
err = os.WriteFile(path, []byte(outs[index]), 0666)
|
||||
ExpectNoError(err)
|
||||
flog.Trace("[%s] %s", path, outs[index])
|
||||
|
||||
@@ -85,7 +85,7 @@ func (f *Framework) RunFrpc(args ...string) (*process.Process, string, error) {
|
||||
func (f *Framework) GenerateConfigFile(content string) string {
|
||||
f.configFileIndex++
|
||||
path := filepath.Join(f.TempDirectory, fmt.Sprintf("frp-e2e-config-%d", f.configFileIndex))
|
||||
err := ioutil.WriteFile(path, []byte(content), 0666)
|
||||
err := os.WriteFile(path, []byte(content), 0666)
|
||||
ExpectNoError(err)
|
||||
return path
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -219,7 +218,7 @@ func (r *Request) sendHTTPRequest(method, urlstr string, host string, headers ma
|
||||
}
|
||||
|
||||
ret := &Response{Code: resp.StatusCode, Header: resp.Header}
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -125,7 +125,7 @@ func (c *Client) do(req *http.Request) (string, error) {
|
||||
if resp.StatusCode != 200 {
|
||||
return "", fmt.Errorf("api status code [%d]", resp.StatusCode)
|
||||
}
|
||||
buf, err := ioutil.ReadAll(resp.Body)
|
||||
buf, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package plugin
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
plugin "github.com/fatedier/frp/pkg/plugin/server"
|
||||
@@ -21,7 +21,7 @@ func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler PluginHandl
|
||||
httpserver.WithTlsConfig(tlsConfig),
|
||||
httpserver.WithHandler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
r := newFunc()
|
||||
buf, err := ioutil.ReadAll(req.Body)
|
||||
buf, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
w.WriteHeader(500)
|
||||
return
|
||||
|
Reference in New Issue
Block a user