From a630a7cda936fe3a80cfe3565409979f77b1bacb Mon Sep 17 00:00:00 2001 From: dudaodong Date: Mon, 29 Jan 2024 10:02:36 +0800 Subject: [PATCH] refactor: remove struct_internal.go --- structs/struct.go | 3 ++- structs/struct_internal.go | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 structs/struct_internal.go diff --git a/structs/struct.go b/structs/struct.go index 8c080d2..14207ed 100644 --- a/structs/struct.go +++ b/structs/struct.go @@ -2,6 +2,7 @@ package structs import ( + "fmt" "reflect" "github.com/duke-git/lancet/v2/pointer" @@ -61,7 +62,7 @@ func New(value any, tagName ...string) *Struct { // ToMap convert the exported fields of a struct to map. func (s *Struct) ToMap() (map[string]any, error) { if !s.IsStruct() { - return nil, errInvalidStruct(s) + return nil, fmt.Errorf("invalid struct %v", s) } result := make(map[string]any) diff --git a/structs/struct_internal.go b/structs/struct_internal.go deleted file mode 100644 index bc147cc..0000000 --- a/structs/struct_internal.go +++ /dev/null @@ -1,7 +0,0 @@ -package structs - -import "fmt" - -func errInvalidStruct(v any) error { - return fmt.Errorf("invalid struct %v", v) -}