Skip to content
Myr

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

19 files+122 added−83 removed

modified:binding/binding_test.go+12 added-12 removed
514 unmodified lines
515 req.Header.Set("Content-Type", MIMEPOSTForm)516 return req517}518519func createFormMultipartRequest() *http.Request {519func createFormMultipartRequest(t *testing.T) *http.Request {520 boundary := "--testboundary"521 body := new(bytes.Buffer)522 mw := multipart.NewWriter(body)523 defer mw.Close()524525 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}532533func createFormMultipartRequestFail() *http.Request {533func createFormMultipartRequestFail(t *testing.T) *http.Request {534 boundary := "--testboundary"535 body := new(bytes.Buffer)536 mw := multipart.NewWriter(body)537 defer mw.Close()538539 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}545546func TestBindingFormPost(t *testing.T) {547 req := createFormPostRequest()548 var obj FooBarStruct549 FormPost.Bind(req, &obj)549 assert.NoError(t, FormPost.Bind(req, &obj))550551 assert.Equal(t, "form-urlencoded", FormPost.Name())552 assert.Equal(t, "bar", obj.Foo)553 assert.Equal(t, "foo", obj.Bar)
1 unmodified line
555556func TestBindingDefaultValueFormPost(t *testing.T) {557 req := createDefaultFormPostRequest()558 var obj FooDefaultBarStruct559 FormPost.Bind(req, &obj)559 assert.NoError(t, FormPost.Bind(req, &obj))560561 assert.Equal(t, "bar", obj.Foo)562 assert.Equal(t, "hello", obj.Bar)563}
5 unmodified lines
569 assert.Error(t, err)570}571572func 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))576577 assert.Equal(t, "multipart/form-data", FormMultipart.Name())578 assert.Equal(t, "bar", obj.Foo)579 assert.Equal(t, "foo", obj.Bar)580}581582func 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 lines
modified:binding/form.go+5 added-1 removed
18 unmodified lines
19func (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 lines
modified:render/json.go+30 added-15 removed
65 unmodified lines
66 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}7374// Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.75func (r IndentedJSON) Render(w http.ResponseWriter) error {
1 unmodified line
77 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}8485// WriteContentType (IndentedJSON) writes JSON ContentType.86func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {
8 unmodified lines
95 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}107108// WriteContentType (SecureJSON) writes JSON ContentType.109func (r SecureJSON) WriteContentType(w http.ResponseWriter) {
8 unmodified lines
118 return err119 }120121 if r.Callback == "" {119 w.Write(ret)120 return nil122 _, err = w.Write(ret)123 return err124 }125126 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 }143144 return nil145}146
18 unmodified lines
165 }166 buffer.WriteString(cvt)167 }168154 w.Write(buffer.Bytes())155 return nil169 _, err = w.Write(buffer.Bytes())170 return err171}172173// WriteContentType (AsciiJSON) writes JSON ContentType.174func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {
2 unmodified lines
modified:render/protobuf.go+2 added-2 removed
24 unmodified lines
25 if err != nil {26 return err27 }2829 w.Write(bytes)30 return nil29 _, err = w.Write(bytes)30 return err31}3233// WriteContentType (ProtoBuf) writes ProtoBuf ContentType.34func (r ProtoBuf) WriteContentType(w http.ResponseWriter) {
2 unmodified lines
modified:render/render_test.go+2 added-2 removed
69 unmodified lines
70 w := httptest.NewRecorder()71 data := make(chan int)7273 // 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}7677func TestRenderIndentedJSON(t *testing.T) {78 w := httptest.NewRecorder()
255 unmodified lines
334 Location: "/new/location",335 }336337 w = httptest.NewRecorder()338 assert.Panics(t, func() { data2.Render(w) })338 assert.Panics(t, func() { assert.NoError(t, data2.Render(w)) })339340 // only improve coverage341 data2.WriteContentType(w)342}
144 unmodified lines
modified:render/text.go+5 added-5 removed
18 unmodified lines
19var plainContentType = []string{"text/plain; charset=utf-8"}2021// Render (String) writes data with custom ContentType.22func (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}2526// WriteContentType (String) writes Plain ContentType.27func (r String) WriteContentType(w http.ResponseWriter) {28 writeContentType(w, plainContentType)29}3031// WriteString writes data according to its format and write custom ContentType.33func WriteString(w http.ResponseWriter, format string, data []interface{}) {32func 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 lines
25 if err != nil {26 return err27 }2829 w.Write(bytes)30 return nil29 _, err = w.Write(bytes)30 return err31}3233// WriteContentType (YAML) writes YAML ContentType for response.34func (r YAML) WriteContentType(w http.ResponseWriter) {
2 unmodified lines
modified:context_test.go+21 added-15 removed
68 unmodified lines
69 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 lines
100101func 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 lines
138 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 lines
161162 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()168169 assert.False(t, c.IsAborted())
630 unmodified lines
800 router.addRoute("GET", "/", HandlersChain{func(_ *Context) {}})801 assert.Len(t, router.trees, 1)802803 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 lines
1213 contentType := w.Header().Get("Content-Type")1214 assert.Equal(t, "application/json; charset=utf-8", contentType)12151216 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}12221223func TestContextError(t *testing.T) {1224 c, _ := CreateTestContext(httptest.NewRecorder())1225 assert.Empty(t, c.Errors)12261223 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())12301227 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 lines
1249 if recover() == nil {1250 t.Error("didn't panic")1251 }1252 }()1249 c.Error(nil)1253 c.Error(nil) // nolint: errcheck1254}12551256func 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: errcheck12601261 for _, err := range c.Errors.ByType(ErrorTypePublic) {1262 assert.Equal(t, ErrorTypePublic, err.Type)1263 }
6 unmodified lines
1270func TestContextAbortWithError(t *testing.T) {1271 w := httptest.NewRecorder()1272 c, _ := CreateTestContext(w)12731270 c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input")1274 c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") // nolint: errcheck12751276 assert.Equal(t, http.StatusUnauthorized, w.Code)1277 assert.Equal(t, abortIndex, c.index)1278 assert.True(t, c.IsAborted())
437 unmodified lines
1716 defer func() {1717 stopStream = false1718 }()17191716 w.Write([]byte("test"))1720 _, err := w.Write([]byte("test"))1721 assert.NoError(t, err)17221723 return stopStream1724 })1725
8 unmodified lines
1734 defer func() {1735 w.closeClient()1736 }()17371733 writer.Write([]byte("test"))1738 _, err := writer.Write([]byte("test"))1739 assert.NoError(t, err)17401741 return true1742 })1743
2 unmodified lines
modified:context.go+15 added-7 removed
413 unmodified lines
414// 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.416func (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 lines
440// GetPostFormMap returns a map for a given form key, plus a boolean value441// whether at least one value exists for the given key.442func (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)450451 if !exist && req.MultipartForm != nil && req.MultipartForm.File != nil {452 dicts, exist = c.get(req.MultipartForm.Value, key)
47 unmodified lines
500 return err501 }502 defer out.Close()503496 io.Copy(out, src)497 return nil504 _, err = io.Copy(out, src)505 return err506}507508// Bind checks the Content-Type to select a binding engine automatically,509// Depending the "Content-Type" header different bindings are used:
31 unmodified lines
541// BindUri binds the passed struct pointer using binding.Uri.542// It will abort the request with HTTP 400 if any error occurs.543func (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 lines
552// It will abort the request with HTTP 400 if any error occurs.553// See the binding package.554func (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 lines
920 data := chooseData(config.XMLData, config.Data)921 c.XML(code, data)922923 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}927928// NegotiateFormat returns an acceptable Accept format.
65 unmodified lines
modified:debug_test.go+10 added-9 removed
30 unmodified lines
31 assert.False(t, IsDebugging())32}3334func 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 lines
45 assert.Equal(t, "[GIN-debug] these are 2 error messages\n", re)46}4748func 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 line
55 assert.Equal(t, "[GIN-debug] [ERROR] this is an error\n", re)56}5758func 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}6667func 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 line
74 assert.Regexp(t, `^\[GIN-debug\] Loaded HTML Templates \(2\): \n(\t- \n|\t- hello\.tmpl\n){2}\n`, re)75}7677func 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}8586func TestDebugPrintWARNINGDefault(t *testing.T) {87 re := captureOutput(func() {87 re := captureOutput(t, func() {88 SetMode(DebugMode)89 debugPrintWARNINGDefault()90 SetMode(TestMode)91 })
5 unmodified lines
97 }98}99100func 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}108109func captureOutput(f func()) string {109func captureOutput(t *testing.T, f func()) string {110 reader, writer, err := os.Pipe()111 if err != nil {112 panic(err)113 }
12 unmodified lines
126 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 lines
modified:errors_test.go+3 added-3 removed
32 unmodified lines
3334 jsonBytes, _ := json.Marshal(err)35 assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))3637 err.SetMeta(H{37 err.SetMeta(H{ // nolint: errcheck38 "status": "200",39 "data": "some data",40 })41 assert.Equal(t, H{
1 unmodified line
43 "status": "200",44 "data": "some data",45 }, err.JSON())4647 err.SetMeta(H{47 err.SetMeta(H{ // nolint: errcheck48 "error": "custom error",49 "status": "200",50 "data": "some data",51 })
6 unmodified lines
58 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}6566func TestErrorSlice(t *testing.T) {
40 unmodified lines
modified:gin_integration_test.go+1 added-1 removed
85 unmodified lines
8687func 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}9394func TestRunWithPort(t *testing.T) {
125 unmodified lines
modified:gin.go+4 added-1 removed
420 unmodified lines
421 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 return
36 unmodified lines
modified:githubapi_test.go+1 added-1 removed
336 unmodified lines
337 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 })343344 path1, _ := exampleFromPath("/new/rest/:num")345 w1 := performRequest(router, "GET", path1)
106 unmodified lines
modified:logger_test.go+3 added-3 removed
276 unmodified lines
277func 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 })290291 w := performRequest(router, "GET", "/error")
51 unmodified lines
modified:middleware_test.go+1 added-1 removed
206 unmodified lines
207 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 lines
modified:recovery.go+1 added-1 removed
64 unmodified lines
65 }6667 // 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 lines
modified:response_writer_test.go+2 added-1 removed
101 unmodified lines
102 writer.reset(testWritter)103 w := ResponseWriter(writer)104105 assert.Panics(t, func() {106 w.Hijack()106 _, _, err := w.Hijack()107 assert.NoError(t, err)108 })109 assert.True(t, w.Written())110111 assert.Panics(t, func() {
21 unmodified lines
modified:routes_test.go+2 added-1 removed
249 unmodified lines
250 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()257258 dir, filename := filepath.Split(f.Name())259
220 unmodified lines