Replace ioutil with io and os (#10541)

* Replace ioutil with io and os

* Fix build errors
This commit is contained in:
Håvard Anda Estensen
2022-04-18 22:42:07 +02:00
committed by GitHub
parent 982de94428
commit d2f4a8cc7c
102 changed files with 256 additions and 291 deletions

View File

@@ -7,7 +7,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@@ -64,13 +64,13 @@ func captureRequest(f *os.File, m map[string]interface{}) error {
}
func parseRequest(req *http.Request, unmarshalStruct interface{}) error {
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
return err
}
if err = req.Body.Close(); err != nil {
return err
}
req.Body = ioutil.NopCloser(bytes.NewBuffer(body))
req.Body = io.NopCloser(bytes.NewBuffer(body))
return json.Unmarshal(body, unmarshalStruct)
}