1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-11-06 08:59:18 +02:00

fix: ci lint error (#1391)

* fix lint check

* fix lll lint error

* fix build error

* fix gomnd

* fix shadow declaration

* add make test command

* update
This commit is contained in:
Kagaya
2021-08-31 10:14:57 +08:00
committed by GitHub
parent a1f35ecc05
commit f7588a47de
71 changed files with 338 additions and 260 deletions

View File

@@ -73,7 +73,7 @@ func Errorf(code int, reason, format string, a ...interface{}) error {
// It supports wrapped errors.
func Code(err error) int {
if err == nil {
return 200
return 200 //nolint:gomnd
}
if se := FromError(err); se != nil {
return int(se.Code)

View File

@@ -8,9 +8,7 @@ import (
)
func TestError(t *testing.T) {
var (
base *Error
)
var base *Error
err := Newf(http.StatusBadRequest, "reason", "message")
err2 := Newf(http.StatusBadRequest, "reason", "message")
err3 := err.WithMetadata(map[string]string{
@@ -45,7 +43,7 @@ func TestError(t *testing.T) {
gs := err.GRPCStatus()
se := FromError(gs.Err())
if se.Reason != se.Reason {
if se.Reason != "reason" {
t.Errorf("got %+v want %+v", se, err)
}
}

View File

@@ -1,3 +1,4 @@
// nolint:gomnd
package errors
// BadRequest new BadRequest error that is mapped to a 400 response.