From 534c7a0abcdf8b7db4abdd40c9ed012e4d324f62 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Wed, 15 Mar 2023 14:58:34 +0800 Subject: [PATCH] refactor: make errInvalidStruct exported, change error.go to struct_internal.go --- structutil/struct.go | 5 +++-- structutil/{error.go => struct_internal.go} | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) rename structutil/{error.go => struct_internal.go} (68%) diff --git a/structutil/struct.go b/structutil/struct.go index eb053b7..69e1288 100644 --- a/structutil/struct.go +++ b/structutil/struct.go @@ -1,8 +1,9 @@ package structutil import ( - "github.com/duke-git/lancet/v2/pointer" "reflect" + + "github.com/duke-git/lancet/v2/pointer" ) // DefaultTagName is the default tag for struct fields to lookup. @@ -49,7 +50,7 @@ func New(value any) *Struct { // Only the exported fields of a struct can be converted. func (s *Struct) ToMap() (map[string]any, error) { if !s.IsStruct() { - return nil, ErrInvalidStruct(s) + return nil, errInvalidStruct(s) } result := make(map[string]any) diff --git a/structutil/error.go b/structutil/struct_internal.go similarity index 68% rename from structutil/error.go rename to structutil/struct_internal.go index 8b808e1..ada0dd2 100644 --- a/structutil/error.go +++ b/structutil/struct_internal.go @@ -2,6 +2,6 @@ package structutil import "fmt" -func ErrInvalidStruct(v any) error { +func errInvalidStruct(v any) error { return fmt.Errorf("invalid struct %v", v) }