Replace ioutil.Discard with io.Discard (#20707)

Этот коммит содержится в:
Tim Scheuermann
2022-07-27 12:40:33 +03:00
коммит произвёл GitHub
родитель c00609ab8e
Коммит eba08cbb11
16 изменённых файлов: 18 добавлений и 30 удалений

Просмотреть файл

@@ -381,7 +381,7 @@ func (th *TestHelper) TearDown() {
func closeBody(r *http.Response) {
if r.Body != nil {
_, _ = io.Copy(ioutil.Discard, r.Body)
_, _ = io.Copy(io.Discard, r.Body)
_ = r.Body.Close()
}
}

Просмотреть файл

@@ -5,7 +5,6 @@ package api4
import (
"io"
"io/ioutil"
"net/http"
"github.com/mattermost/mattermost-server/v6/audit"
@@ -33,7 +32,7 @@ func getBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
}
func uploadBrandImage(c *Context, w http.ResponseWriter, r *http.Request) {
defer io.Copy(ioutil.Discard, r.Body)
defer io.Copy(io.Discard, r.Body)
if r.ContentLength > *c.App.Config().FileSettings.MaxFileSize {
c.Err = model.NewAppError("uploadBrandImage", "api.admin.upload_brand_image.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge)

Просмотреть файл

@@ -6,7 +6,6 @@ package api4
import (
"encoding/json"
"io"
"io/ioutil"
"net/http"
"github.com/mattermost/mattermost-server/v6/app"
@@ -32,7 +31,7 @@ func (api *API) InitEmoji() {
}
func createEmoji(c *Context, w http.ResponseWriter, r *http.Request) {
defer io.Copy(ioutil.Discard, r.Body)
defer io.Copy(io.Discard, r.Body)
if !*c.App.Config().ServiceSettings.EnableCustomEmoji {
c.Err = model.NewAppError("createEmoji", "api.emoji.disabled.app_error", nil, "", http.StatusNotImplemented)

Просмотреть файл

@@ -6,7 +6,6 @@ package api4
import (
"encoding/json"
"io"
"io/ioutil"
"net/http"
"time"
@@ -222,7 +221,7 @@ func uploadRemoteData(c *Context, w http.ResponseWriter, r *http.Request) {
}
func remoteSetProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
defer io.Copy(ioutil.Discard, r.Body)
defer io.Copy(io.Discard, r.Body)
c.RequireUserId()
if c.Err != nil {

Просмотреть файл

@@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"path"
"reflect"
@@ -527,7 +526,7 @@ func getRedirectLocation(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
defer func() {
io.Copy(ioutil.Discard, res.Body)
io.Copy(io.Discard, res.Body)
res.Body.Close()
}()

Просмотреть файл

@@ -9,7 +9,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"regexp"
"strconv"
@@ -1610,7 +1609,7 @@ func getTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
}
func setTeamIcon(c *Context, w http.ResponseWriter, r *http.Request) {
defer io.Copy(ioutil.Discard, r.Body)
defer io.Copy(io.Discard, r.Body)
c.RequireTeamId()
if c.Err != nil {

Просмотреть файл

@@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
"strings"
@@ -419,7 +418,7 @@ func getProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
}
func setProfileImage(c *Context, w http.ResponseWriter, r *http.Request) {
defer io.Copy(ioutil.Discard, r.Body)
defer io.Copy(io.Discard, r.Body)
c.RequireUserId()
if c.Err != nil {