Smart generating error code and response for gin mux based on passed error.
package main
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
"github.com/microparts/errors-go-gin"
)
func main() {
r := gin.New()
r.GET("/", func(c*gin.Context) {c.JSON(http.StatusOK,`{"status":"ok"}`)})
r.GET("/err", func(c *gin.Context) { ginerrors.Response(c, errors.New("error")) })
_ = r.Run(":8080")
}
Lint code with golangci-lint and custom config for it:
make lint
Test code with race checking and generation coverage profile:
make test