Categorygithub.com/zeroabe/errors-go-gin
modulepackage
0.6.2
Repository: https://github.com/zeroabe/errors-go-gin.git
Documentation: pkg.go.dev

# README

ginerrors

Smart generating error code and response for gin mux based on passed error.

Usage

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")
}

Linter

Lint code with golangci-lint and custom config for it:

make lint

Testing

Test code with race checking and generation coverage profile:

make test

# Functions

HasErrors checks if error occurs in passed err.
Response makes common error response.
New returns new error with passed message.
Newf returns new error with message sprintf'ed by format with passed params.
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author