gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
78.97k stars 8.02k forks source link

[proposal] save the `return` line #3116

Open mozhata opened 2 years ago

mozhata commented 2 years ago

Description

gin should do something to save the return line

How to reproduce

when met an error we use to lines to deal with it

    var err error 
    if err != nil{
        c.Status(http.StatusInternalServerError)
        return
    }

It will be cool to use return c.Status(http.StatusInternalServerError) or provide some alike method to support this

arshabbir commented 2 years ago

@easonlin404

Please review

https://github.com/gin-gonic/gin/pull/3140

Added error return for c.Status(code) so that this can be used as return c.Status(code) to avoid/save extra return statement