fix errcheck warnings (#1739)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Dmitry Kutakov · committed by thinkerou · parent 29a145c · Browse files · 19 files·+122 added−83 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
19 files+122 added−83 removed
- other:+122 added−83 removed
Provenance
- Commit
b056a34- Tree
fc8d152- Author
Dmitry Kutakov <vkd.castle@gmail.com>- Committer
thinkerou <thinkerou@gmail.com>- Parent
29a145c
19 files changed+122 added−83 removed
modified:binding/binding_test.go+12 added-12 removed
514 unmodified lines515 req.Header.Set("Content-Type", MIMEPOSTForm)516 return req517 }518 519-func createFormMultipartRequest() *http.Request {519+func createFormMultipartRequest(t *testing.T) *http.Request {520 boundary := "--testboundary"521 body := new(bytes.Buffer)522 mw := multipart.NewWriter(body)523 defer mw.Close()524 525- mw.SetBoundary(boundary)526- mw.WriteField("foo", "bar")527- mw.WriteField("bar", "foo")525+ assert.NoError(t, mw.SetBoundary(boundary))526+ assert.NoError(t, mw.WriteField("foo", "bar"))527+ assert.NoError(t, mw.WriteField("bar", "foo"))528 req, _ := http.NewRequest("POST", "/?foo=getfoo&bar=getbar", body)529 req.Header.Set("Content-Type", MIMEMultipartPOSTForm+"; boundary="+boundary)530 return req531 }532 533-func createFormMultipartRequestFail() *http.Request {533+func createFormMultipartRequestFail(t *testing.T) *http.Request {534 boundary := "--testboundary"535 body := new(bytes.Buffer)536 mw := multipart.NewWriter(body)537 defer mw.Close()538 539- mw.SetBoundary(boundary)540- mw.WriteField("map_foo", "bar")539+ assert.NoError(t, mw.SetBoundary(boundary))540+ assert.NoError(t, mw.WriteField("map_foo", "bar"))541 req, _ := http.NewRequest("POST", "/?map_foo=getfoo", body)542 req.Header.Set("Content-Type", MIMEMultipartPOSTForm+"; boundary="+boundary)543 return req544 }545 546 func TestBindingFormPost(t *testing.T) {547 req := createFormPostRequest()548 var obj FooBarStruct549- FormPost.Bind(req, &obj)549+ assert.NoError(t, FormPost.Bind(req, &obj))550 551 assert.Equal(t, "form-urlencoded", FormPost.Name())552 assert.Equal(t, "bar", obj.Foo)553 assert.Equal(t, "foo", obj.Bar)1 unmodified line555 556 func TestBindingDefaultValueFormPost(t *testing.T) {557 req := createDefaultFormPostRequest()558 var obj FooDefaultBarStruct559- FormPost.Bind(req, &obj)559+ assert.NoError(t, FormPost.Bind(req, &obj))560 561 assert.Equal(t, "bar", obj.Foo)562 assert.Equal(t, "hello", obj.Bar)563 }5 unmodified lines569 assert.Error(t, err)570 }571 572 func TestBindingFormMultipart(t *testing.T) {573- req := createFormMultipartRequest()573+ req := createFormMultipartRequest(t)574 var obj FooBarStruct575- FormMultipart.Bind(req, &obj)575+ assert.NoError(t, FormMultipart.Bind(req, &obj))576 577 assert.Equal(t, "multipart/form-data", FormMultipart.Name())578 assert.Equal(t, "bar", obj.Foo)579 assert.Equal(t, "foo", obj.Bar)580 }581 582 func TestBindingFormMultipartFail(t *testing.T) {583- req := createFormMultipartRequestFail()583+ req := createFormMultipartRequestFail(t)584 var obj FooStructForMapType585 err := FormMultipart.Bind(req, &obj)586 assert.Error(t, err)587 }707 unmodified linesmodified:binding/form.go+5 added-1 removed
18 unmodified lines19 func (formBinding) Bind(req *http.Request, obj interface{}) error {20 if err := req.ParseForm(); err != nil {21 return err22 }23- req.ParseMultipartForm(defaultMemory)23+ if err := req.ParseMultipartForm(defaultMemory); err != nil {24+ if err != http.ErrNotMultipart {25+ return err26+ }27+ }28 if err := mapForm(obj, req.Form); err != nil {29 return err30 }31 return validate(obj)29 unmodified linesmodified:render/json.go+30 added-15 removed
65 unmodified lines66 jsonBytes, err := json.Marshal(obj)67 if err != nil {68 return err69 }70- w.Write(jsonBytes)71- return nil70+ _, err = w.Write(jsonBytes)71+ return err72 }73 74 // Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.75 func (r IndentedJSON) Render(w http.ResponseWriter) error {1 unmodified line77 jsonBytes, err := json.MarshalIndent(r.Data, "", " ")78 if err != nil {79 return err80 }81- w.Write(jsonBytes)82- return nil81+ _, err = w.Write(jsonBytes)82+ return err83 }84 85 // WriteContentType (IndentedJSON) writes JSON ContentType.86 func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {8 unmodified lines95 return err96 }97 // if the jsonBytes is array values98 if bytes.HasPrefix(jsonBytes, []byte("[")) && bytes.HasSuffix(jsonBytes, []byte("]")) {99- w.Write([]byte(r.Prefix))99+ _, err = w.Write([]byte(r.Prefix))100+ if err != nil {101+ return err102+ }103 }101- w.Write(jsonBytes)102- return nil104+ _, err = w.Write(jsonBytes)105+ return err106 }107 108 // WriteContentType (SecureJSON) writes JSON ContentType.109 func (r SecureJSON) WriteContentType(w http.ResponseWriter) {8 unmodified lines118 return err119 }120 121 if r.Callback == "" {119- w.Write(ret)120- return nil122+ _, err = w.Write(ret)123+ return err124 }125 126 callback := template.JSEscapeString(r.Callback)124- w.Write([]byte(callback))125- w.Write([]byte("("))126- w.Write(ret)127- w.Write([]byte(")"))127+ _, err = w.Write([]byte(callback))128+ if err != nil {129+ return err130+ }131+ _, err = w.Write([]byte("("))132+ if err != nil {133+ return err134+ }135+ _, err = w.Write(ret)136+ if err != nil {137+ return err138+ }139+ _, err = w.Write([]byte(")"))140+ if err != nil {141+ return err142+ }143 144 return nil145 }146 18 unmodified lines165 }166 buffer.WriteString(cvt)167 }168 154- w.Write(buffer.Bytes())155- return nil169+ _, err = w.Write(buffer.Bytes())170+ return err171 }172 173 // WriteContentType (AsciiJSON) writes JSON ContentType.174 func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {2 unmodified linesmodified:render/protobuf.go+2 added-2 removed
24 unmodified lines25 if err != nil {26 return err27 }28 29- w.Write(bytes)30- return nil29+ _, err = w.Write(bytes)30+ return err31 }32 33 // WriteContentType (ProtoBuf) writes ProtoBuf ContentType.34 func (r ProtoBuf) WriteContentType(w http.ResponseWriter) {2 unmodified linesmodified:render/render_test.go+2 added-2 removed
69 unmodified lines70 w := httptest.NewRecorder()71 data := make(chan int)72 73 // json: unsupported type: chan int74- assert.Panics(t, func() { (JSON{data}).Render(w) })74+ assert.Panics(t, func() { assert.NoError(t, (JSON{data}).Render(w)) })75 }76 77 func TestRenderIndentedJSON(t *testing.T) {78 w := httptest.NewRecorder()255 unmodified lines334 Location: "/new/location",335 }336 337 w = httptest.NewRecorder()338- assert.Panics(t, func() { data2.Render(w) })338+ assert.Panics(t, func() { assert.NoError(t, data2.Render(w)) })339 340 // only improve coverage341 data2.WriteContentType(w)342 }144 unmodified linesmodified:render/text.go+5 added-5 removed
18 unmodified lines19 var plainContentType = []string{"text/plain; charset=utf-8"}20 21 // Render (String) writes data with custom ContentType.22 func (r String) Render(w http.ResponseWriter) error {23- WriteString(w, r.Format, r.Data)24- return nil23+ return WriteString(w, r.Format, r.Data)24 }25 26 // WriteContentType (String) writes Plain ContentType.27 func (r String) WriteContentType(w http.ResponseWriter) {28 writeContentType(w, plainContentType)29 }30 31 // WriteString writes data according to its format and write custom ContentType.33-func WriteString(w http.ResponseWriter, format string, data []interface{}) {32+func WriteString(w http.ResponseWriter, format string, data []interface{}) (err error) {33 writeContentType(w, plainContentType)34 if len(data) > 0 {36- fmt.Fprintf(w, format, data...)35+ _, err = fmt.Fprintf(w, format, data...)36 return37 }39- io.WriteString(w, format)38+ _, err = io.WriteString(w, format)39+ return40 }modified:render/yaml.go+2 added-2 removed
24 unmodified lines25 if err != nil {26 return err27 }28 29- w.Write(bytes)30- return nil29+ _, err = w.Write(bytes)30+ return err31 }32 33 // WriteContentType (YAML) writes YAML ContentType for response.34 func (r YAML) WriteContentType(w http.ResponseWriter) {2 unmodified linesmodified:context_test.go+21 added-15 removed
68 unmodified lines69 buf := new(bytes.Buffer)70 mw := multipart.NewWriter(buf)71 w, err := mw.CreateFormFile("file", "test")72 if assert.NoError(t, err) {73- w.Write([]byte("test"))73+ _, err = w.Write([]byte("test"))74+ assert.NoError(t, err)75 }76 mw.Close()77 c, _ := CreateTestContext(httptest.NewRecorder())78 c.Request, _ = http.NewRequest("POST", "/", buf)21 unmodified lines100 101 func TestContextMultipartForm(t *testing.T) {102 buf := new(bytes.Buffer)103 mw := multipart.NewWriter(buf)103- mw.WriteField("foo", "bar")104+ assert.NoError(t, mw.WriteField("foo", "bar"))105 w, err := mw.CreateFormFile("file", "test")106 if assert.NoError(t, err) {106- w.Write([]byte("test"))107+ _, err = w.Write([]byte("test"))108+ assert.NoError(t, err)109 }110 mw.Close()111 c, _ := CreateTestContext(httptest.NewRecorder())112 c.Request, _ = http.NewRequest("POST", "/", buf)25 unmodified lines138 buf := new(bytes.Buffer)139 mw := multipart.NewWriter(buf)140 w, err := mw.CreateFormFile("file", "test")141 if assert.NoError(t, err) {140- w.Write([]byte("test"))142+ _, err = w.Write([]byte("test"))143+ assert.NoError(t, err)144 }145 mw.Close()146 c, _ := CreateTestContext(httptest.NewRecorder())147 c.Request, _ = http.NewRequest("POST", "/", buf)13 unmodified lines161 162 c.index = 2163 c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()}164 c.Params = Params{Param{}}162- c.Error(errors.New("test"))165+ c.Error(errors.New("test")) // nolint: errcheck166 c.Set("foo", "bar")167 c.reset()168 169 assert.False(t, c.IsAborted())630 unmodified lines800 router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})801 assert.Len(t, router.trees, 1)802 803 templ := template.Must(template.New("t").Parse(`Hello {{.name}}`))801- re := captureOutput(func() {804+ re := captureOutput(t, func() {805 SetMode(DebugMode)806 router.SetHTMLTemplate(templ)807 SetMode(TestMode)808 })404 unmodified lines1213 contentType := w.Header().Get("Content-Type")1214 assert.Equal(t, "application/json; charset=utf-8", contentType)1215 1216 buf := new(bytes.Buffer)1214- buf.ReadFrom(w.Body)1217+ _, err := buf.ReadFrom(w.Body)1218+ assert.NoError(t, err)1219 jsonStringBody := buf.String()1220 assert.Equal(t, fmt.Sprint(`{"foo":"fooValue","bar":"barValue"}`), jsonStringBody)1221 }1222 1223 func TestContextError(t *testing.T) {1224 c, _ := CreateTestContext(httptest.NewRecorder())1225 assert.Empty(t, c.Errors)1226 1223- c.Error(errors.New("first error"))1227+ c.Error(errors.New("first error")) // nolint: errcheck1228 assert.Len(t, c.Errors, 1)1229 assert.Equal(t, "Error #01: first error\n", c.Errors.String())1230 1227- c.Error(&Error{1231+ c.Error(&Error{ // nolint: errcheck1232 Err: errors.New("second error"),1233 Meta: "some data 2",1234 Type: ErrorTypePublic,1235 })13 unmodified lines1249 if recover() == nil {1250 t.Error("didn't panic")1251 }1252 }()1249- c.Error(nil)1253+ c.Error(nil) // nolint: errcheck1254 }1255 1256 func TestContextTypedError(t *testing.T) {1257 c, _ := CreateTestContext(httptest.NewRecorder())1254- c.Error(errors.New("externo 0")).SetType(ErrorTypePublic)1255- c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate)1258+ c.Error(errors.New("externo 0")).SetType(ErrorTypePublic) // nolint: errcheck1259+ c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) // nolint: errcheck1260 1261 for _, err := range c.Errors.ByType(ErrorTypePublic) {1262 assert.Equal(t, ErrorTypePublic, err.Type)1263 }6 unmodified lines1270 func TestContextAbortWithError(t *testing.T) {1271 w := httptest.NewRecorder()1272 c, _ := CreateTestContext(w)1273 1270- c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input")1274+ c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") // nolint: errcheck1275 1276 assert.Equal(t, http.StatusUnauthorized, w.Code)1277 assert.Equal(t, abortIndex, c.index)1278 assert.True(t, c.IsAborted())437 unmodified lines1716 defer func() {1717 stopStream = false1718 }()1719 1716- w.Write([]byte("test"))1720+ _, err := w.Write([]byte("test"))1721+ assert.NoError(t, err)1722 1723 return stopStream1724 })1725 8 unmodified lines1734 defer func() {1735 w.closeClient()1736 }()1737 1733- writer.Write([]byte("test"))1738+ _, err := writer.Write([]byte("test"))1739+ assert.NoError(t, err)1740 1741 return true1742 })1743 2 unmodified linesmodified:context.go+15 added-7 removed
413 unmodified lines414 // GetPostFormArray returns a slice of strings for a given form key, plus415 // a boolean value whether at least one value exists for the given key.416 func (c *Context) GetPostFormArray(key string) ([]string, bool) {417 req := c.Request418- req.ParseMultipartForm(c.engine.MaxMultipartMemory)418+ if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {419+ if err != http.ErrNotMultipart {420+ debugPrint("error on parse multipart form array: %v", err)421+ }422+ }423 if values := req.PostForm[key]; len(values) > 0 {424 return values, true425 }426 if req.MultipartForm != nil && req.MultipartForm.File != nil {13 unmodified lines440 // GetPostFormMap returns a map for a given form key, plus a boolean value441 // whether at least one value exists for the given key.442 func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {443 req := c.Request440- req.ParseMultipartForm(c.engine.MaxMultipartMemory)444+ if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {445+ if err != http.ErrNotMultipart {446+ debugPrint("error on parse multipart form map: %v", err)447+ }448+ }449 dicts, exist := c.get(req.PostForm, key)450 451 if !exist && req.MultipartForm != nil && req.MultipartForm.File != nil {452 dicts, exist = c.get(req.MultipartForm.Value, key)47 unmodified lines500 return err501 }502 defer out.Close()503 496- io.Copy(out, src)497- return nil504+ _, err = io.Copy(out, src)505+ return err506 }507 508 // Bind checks the Content-Type to select a binding engine automatically,509 // Depending the "Content-Type" header different bindings are used:31 unmodified lines541 // BindUri binds the passed struct pointer using binding.Uri.542 // It will abort the request with HTTP 400 if any error occurs.543 func (c *Context) BindUri(obj interface{}) error {544 if err := c.ShouldBindUri(obj); err != nil {537- c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind)545+ c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck546 return err547 }548 return nil549 }2 unmodified lines552 // It will abort the request with HTTP 400 if any error occurs.553 // See the binding package.554 func (c *Context) MustBindWith(obj interface{}, b binding.Binding) error {555 if err := c.ShouldBindWith(obj, b); err != nil {548- c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind)556+ c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck557 return err558 }559 return nil560 }359 unmodified lines920 data := chooseData(config.XMLData, config.Data)921 c.XML(code, data)922 923 default:916- c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server"))924+ c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) // nolint: errcheck925 }926 }927 928 // NegotiateFormat returns an acceptable Accept format.65 unmodified linesmodified:debug_test.go+10 added-9 removed
30 unmodified lines31 assert.False(t, IsDebugging())32 }33 34 func TestDebugPrint(t *testing.T) {35- re := captureOutput(func() {35+ re := captureOutput(t, func() {36 SetMode(DebugMode)37 SetMode(ReleaseMode)38 debugPrint("DEBUG this!")39 SetMode(TestMode)5 unmodified lines45 assert.Equal(t, "[GIN-debug] these are 2 error messages\n", re)46 }47 48 func TestDebugPrintError(t *testing.T) {49- re := captureOutput(func() {49+ re := captureOutput(t, func() {50 SetMode(DebugMode)51 debugPrintError(nil)52 debugPrintError(errors.New("this is an error"))53 SetMode(TestMode)1 unmodified line55 assert.Equal(t, "[GIN-debug] [ERROR] this is an error\n", re)56 }57 58 func TestDebugPrintRoutes(t *testing.T) {59- re := captureOutput(func() {59+ re := captureOutput(t, func() {60 SetMode(DebugMode)61 debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest})62 SetMode(TestMode)63 })64 assert.Regexp(t, `^\[GIN-debug\] GET /path/to/route/:param --> (.*/vendor/)?github.com/gin-gonic/gin.handlerNameTest \(2 handlers\)\n$`, re)65 }66 67 func TestDebugPrintLoadTemplate(t *testing.T) {68- re := captureOutput(func() {68+ re := captureOutput(t, func() {69 SetMode(DebugMode)70 templ := template.Must(template.New("").Delims("{[{", "}]}").ParseGlob("./testdata/template/hello.tmpl"))71 debugPrintLoadTemplate(templ)72 SetMode(TestMode)1 unmodified line74 assert.Regexp(t, `^\[GIN-debug\] Loaded HTML Templates \(2\): \n(\t- \n|\t- hello\.tmpl\n){2}\n`, re)75 }76 77 func TestDebugPrintWARNINGSetHTMLTemplate(t *testing.T) {78- re := captureOutput(func() {78+ re := captureOutput(t, func() {79 SetMode(DebugMode)80 debugPrintWARNINGSetHTMLTemplate()81 SetMode(TestMode)82 })83 assert.Equal(t, "[GIN-debug] [WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called\nat initialization. ie. before any route is registered or the router is listening in a socket:\n\n\trouter := gin.Default()\n\trouter.SetHTMLTemplate(template) // << good place\n\n", re)84 }85 86 func TestDebugPrintWARNINGDefault(t *testing.T) {87- re := captureOutput(func() {87+ re := captureOutput(t, func() {88 SetMode(DebugMode)89 debugPrintWARNINGDefault()90 SetMode(TestMode)91 })5 unmodified lines97 }98 }99 100 func TestDebugPrintWARNINGNew(t *testing.T) {101- re := captureOutput(func() {101+ re := captureOutput(t, func() {102 SetMode(DebugMode)103 debugPrintWARNINGNew()104 SetMode(TestMode)105 })106 assert.Equal(t, "[GIN-debug] [WARNING] Running in \"debug\" mode. Switch to \"release\" mode in production.\n - using env:\texport GIN_MODE=release\n - using code:\tgin.SetMode(gin.ReleaseMode)\n\n", re)107 }108 109-func captureOutput(f func()) string {109+func captureOutput(t *testing.T, f func()) string {110 reader, writer, err := os.Pipe()111 if err != nil {112 panic(err)113 }12 unmodified lines126 wg.Add(1)127 go func() {128 var buf bytes.Buffer129 wg.Done()130- io.Copy(&buf, reader)130+ _, err := io.Copy(&buf, reader)131+ assert.NoError(t, err)132 out <- buf.String()133 }()134 wg.Wait()135 f()18 unmodified linesmodified:errors_test.go+3 added-3 removed
32 unmodified lines33 34 jsonBytes, _ := json.Marshal(err)35 assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))36 37- err.SetMeta(H{37+ err.SetMeta(H{ // nolint: errcheck38 "status": "200",39 "data": "some data",40 })41 assert.Equal(t, H{1 unmodified line43 "status": "200",44 "data": "some data",45 }, err.JSON())46 47- err.SetMeta(H{47+ err.SetMeta(H{ // nolint: errcheck48 "error": "custom error",49 "status": "200",50 "data": "some data",51 })6 unmodified lines58 type customError struct {59 status string60 data string61 }62- err.SetMeta(customError{status: "200", data: "other data"})62+ err.SetMeta(customError{status: "200", data: "other data"}) // nolint: errcheck63 assert.Equal(t, customError{status: "200", data: "other data"}, err.JSON())64 }65 66 func TestErrorSlice(t *testing.T) {40 unmodified linesmodified:gin_integration_test.go+1 added-1 removed
85 unmodified lines86 87 func TestRunTooMuchParams(t *testing.T) {88 router := New()89 assert.Panics(t, func() {90- router.Run("2", "2")90+ assert.NoError(t, router.Run("2", "2"))91 })92 }93 94 func TestRunWithPort(t *testing.T) {125 unmodified linesmodified:gin.go+4 added-1 removed
420 unmodified lines421 return422 }423 if c.writermem.Status() == code {424 c.writermem.Header()["Content-Type"] = mimePlain425- c.Writer.Write(defaultMessage)425+ _, err := c.Writer.Write(defaultMessage)426+ if err != nil {427+ debugPrint("cannot write message to writer during serve error: %v", err)428+ }429 return430 }431 c.writermem.WriteHeaderNow()432 return36 unmodified linesmodified:githubapi_test.go+1 added-1 removed
336 unmodified lines337 Number string `uri:"num" binding:"required,uuid"`338 }339 router.Handle("GET", "/new/rest/:num", func(c *Context) {340 var m Member341- c.BindUri(&m)341+ assert.Error(t, c.BindUri(&m))342 })343 344 path1, _ := exampleFromPath("/new/rest/:num")345 w1 := performRequest(router, "GET", path1)106 unmodified linesmodified:logger_test.go+3 added-3 removed
276 unmodified lines277 func TestErrorLogger(t *testing.T) {278 router := New()279 router.Use(ErrorLogger())280 router.GET("/error", func(c *Context) {281- c.Error(errors.New("this is an error"))281+ c.Error(errors.New("this is an error")) // nolint: errcheck282 })283 router.GET("/abort", func(c *Context) {284- c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized"))284+ c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized")) // nolint: errcheck285 })286 router.GET("/print", func(c *Context) {287- c.Error(errors.New("this is an error"))287+ c.Error(errors.New("this is an error")) // nolint: errcheck288 c.String(http.StatusInternalServerError, "hola!")289 })290 291 w := performRequest(router, "GET", "/error")51 unmodified linesmodified:middleware_test.go+1 added-1 removed
206 unmodified lines207 signature := ""208 router := New()209 router.Use(func(context *Context) {210 signature += "A"211- context.AbortWithError(http.StatusInternalServerError, errors.New("foo"))211+ context.AbortWithError(http.StatusInternalServerError, errors.New("foo")) // nolint: errcheck212 })213 router.Use(func(context *Context) {214 signature += "B"215 context.Next()35 unmodified linesmodified:recovery.go+1 added-1 removed
64 unmodified lines65 }66 67 // If the connection is dead, we can't write a status to it.68 if brokenPipe {69- c.Error(err.(error))69+ c.Error(err.(error)) // nolint: errcheck70 c.Abort()71 } else {72 c.AbortWithStatus(http.StatusInternalServerError)73 }71 unmodified linesmodified:response_writer_test.go+2 added-1 removed
101 unmodified lines102 writer.reset(testWritter)103 w := ResponseWriter(writer)104 105 assert.Panics(t, func() {106- w.Hijack()106+ _, _, err := w.Hijack()107+ assert.NoError(t, err)108 })109 assert.True(t, w.Written())110 111 assert.Panics(t, func() {21 unmodified linesmodified:routes_test.go+2 added-1 removed
249 unmodified lines250 if err != nil {251 t.Error(err)252 }253 defer os.Remove(f.Name())254- f.WriteString("Gin Web Framework")254+ _, err = f.WriteString("Gin Web Framework")255+ assert.NoError(t, err)256 f.Close()257 258 dir, filename := filepath.Split(f.Name())259 220 unmodified lines