mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-14 17:52:28 +08:00
refactor: make errInvalidStruct exported, change error.go to struct_internal.go
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
package structutil
|
package structutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/duke-git/lancet/v2/pointer"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/duke-git/lancet/v2/pointer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultTagName is the default tag for struct fields to lookup.
|
// 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.
|
// Only the exported fields of a struct can be converted.
|
||||||
func (s *Struct) ToMap() (map[string]any, error) {
|
func (s *Struct) ToMap() (map[string]any, error) {
|
||||||
if !s.IsStruct() {
|
if !s.IsStruct() {
|
||||||
return nil, ErrInvalidStruct(s)
|
return nil, errInvalidStruct(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]any)
|
result := make(map[string]any)
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ package structutil
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func ErrInvalidStruct(v any) error {
|
func errInvalidStruct(v any) error {
|
||||||
return fmt.Errorf("invalid struct %v", v)
|
return fmt.Errorf("invalid struct %v", v)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user