Fix 'errcheck' linter warnings (#2093)
This commit is contained in:
committed by
thinkerou
parent
8a1bfcfd3b
commit
393a63f3b0
@ -441,7 +441,8 @@ func createFormFilesMultipartRequest(t *testing.T) *http.Request {
|
||||
defer f.Close()
|
||||
fw, err1 := mw.CreateFormFile("file", "form.go")
|
||||
assert.NoError(t, err1)
|
||||
io.Copy(fw, f)
|
||||
_, err = io.Copy(fw, f)
|
||||
assert.NoError(t, err)
|
||||
|
||||
req, err2 := http.NewRequest("POST", "/?foo=getfoo&bar=getbar", body)
|
||||
assert.NoError(t, err2)
|
||||
@ -465,7 +466,8 @@ func createFormFilesMultipartRequestFail(t *testing.T) *http.Request {
|
||||
defer f.Close()
|
||||
fw, err1 := mw.CreateFormFile("file_foo", "form_foo.go")
|
||||
assert.NoError(t, err1)
|
||||
io.Copy(fw, f)
|
||||
_, err = io.Copy(fw, f)
|
||||
assert.NoError(t, err)
|
||||
|
||||
req, err2 := http.NewRequest("POST", "/?foo=getfoo&bar=getbar", body)
|
||||
assert.NoError(t, err2)
|
||||
@ -554,7 +556,8 @@ func TestBindingFormPostForMapFail(t *testing.T) {
|
||||
func TestBindingFormFilesMultipart(t *testing.T) {
|
||||
req := createFormFilesMultipartRequest(t)
|
||||
var obj FooBarFileStruct
|
||||
FormMultipart.Bind(req, &obj)
|
||||
err := FormMultipart.Bind(req, &obj)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// file from os
|
||||
f, _ := os.Open("form.go")
|
||||
|
@ -32,7 +32,10 @@ type structFull struct {
|
||||
func BenchmarkMapFormFull(b *testing.B) {
|
||||
var s structFull
|
||||
for i := 0; i < b.N; i++ {
|
||||
mapForm(&s, form)
|
||||
err := mapForm(&s, form)
|
||||
if err != nil {
|
||||
b.Fatalf("Error on a form mapping")
|
||||
}
|
||||
}
|
||||
b.StopTimer()
|
||||
|
||||
@ -52,7 +55,10 @@ type structName struct {
|
||||
func BenchmarkMapFormName(b *testing.B) {
|
||||
var s structName
|
||||
for i := 0; i < b.N; i++ {
|
||||
mapForm(&s, form)
|
||||
err := mapForm(&s, form)
|
||||
if err != nil {
|
||||
b.Fatalf("Error on a form mapping")
|
||||
}
|
||||
}
|
||||
b.StopTimer()
|
||||
|
||||
|
Reference in New Issue
Block a user