refactor: move from io/ioutil to io and os packages (#5266)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. [1]: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -18,9 +18,9 @@ package es
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -158,7 +158,7 @@ func TestOpensearchClient_Search(t *testing.T) {
|
||||
func mockElasticsearchService(pattern, fakeResp string, fakeCode int) *httptest.Server {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc(pattern, func(res http.ResponseWriter, req *http.Request) {
|
||||
b, _ := ioutil.ReadFile(fmt.Sprintf("./testdata/%s", fakeResp))
|
||||
b, _ := os.ReadFile(fmt.Sprintf("./testdata/%s", fakeResp))
|
||||
res.WriteHeader(fakeCode)
|
||||
res.Write(b)
|
||||
})
|
||||
@@ -166,7 +166,7 @@ func mockElasticsearchService(pattern, fakeResp string, fakeCode int) *httptest.
|
||||
}
|
||||
|
||||
func JsonFromFile(expectedFile string, expectedJsonPtr interface{}) error {
|
||||
json, err := ioutil.ReadFile(fmt.Sprintf("./testdata/%s", expectedFile))
|
||||
json, err := os.ReadFile(fmt.Sprintf("./testdata/%s", expectedFile))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user