https://github.com/spacetab-io/errors-gin-go
https://github.com/spacetab-io/errors-gin-go
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/spacetab-io/errors-gin-go
- Owner: spacetab-io
- Created: 2020-05-19T05:32:21.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-05T21:13:35.000Z (almost 2 years ago)
- Last Synced: 2025-02-14T22:13:53.412Z (3 months ago)
- Language: Go
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ginerrors
Smart generating error code and response for gin mux based on passed error.
## Usage
```go
package mainimport (
"errors"
"net/http""github.com/gin-gonic/gin"
"github.com/spacetab-io/errors-gin-go"
)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")
}
```## Linter
Lint code with [golangci-lint](https://github.com/golangci/golangci-lint) and
[custom config](https://github.com/spacetab-io/linter-go/blob/master/.golangci.yml) for it:make lint
## Testing
Test code with race checking and generation coverage profile:
make tests