From 2a9b1a0cf732109bde9f6078f631880e20ab5c19 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Tue, 29 Oct 2024 00:34:24 +0700 Subject: [PATCH] fix lint errors --- cmd/hasura-ndc-go/command/internal/constant.go | 1 - utils/decode.go | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/hasura-ndc-go/command/internal/constant.go b/cmd/hasura-ndc-go/command/internal/constant.go index f6e7948..77529f2 100644 --- a/cmd/hasura-ndc-go/command/internal/constant.go +++ b/cmd/hasura-ndc-go/command/internal/constant.go @@ -146,7 +146,6 @@ var ( ndcScalarNameRegex = regexp.MustCompile(`^Scalar([A-Z]\w*)$`) ndcScalarCommentRegex = regexp.MustCompile(`^@scalar(\s+(\w+))?(\s+([a-z]+))?$`) ndcEnumCommentRegex = regexp.MustCompile(`^@enum\s+([\w-.,!@#$%^&*()+=~\s\t]+)$`) - packagePathRegex = regexp.MustCompile(`(([\w-\.]+/)+[a-z]+)\.`) ) var ( diff --git a/utils/decode.go b/utils/decode.go index 995b8bb..5230de9 100644 --- a/utils/decode.go +++ b/utils/decode.go @@ -26,10 +26,9 @@ type ( ) var ( - errIntRequired = errors.New("the Int value must not be null") - errUintRequired = errors.New("the Uint value must not be null") - errValueTargetRequired = errors.New("the decoded target must be a pointer and not null") - errValueRequired = errors.New("the value must not be null") + errIntRequired = errors.New("the Int value must not be null") + errUintRequired = errors.New("the Uint value must not be null") + errValueRequired = errors.New("the value must not be null") ) // ValueDecoder abstracts a type with the FromValue method to decode any value. @@ -201,7 +200,7 @@ func DecodeObject[T any](value map[string]any, decodeHooks ...mapstructure.Decod if t, ok := any(result).(ObjectDecoder); ok { if err := t.FromValue(value); err != nil { - return *result, nil + return *result, err } } @@ -222,7 +221,7 @@ func DecodeNullableObject[T any](value map[string]any, decodeHooks ...mapstructu if t, ok := any(result).(ObjectDecoder); ok { if err := t.FromValue(value); err != nil { - return nil, nil + return nil, err } }