1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 07:02:29 +08:00

fix: fix goline error

This commit is contained in:
dudaodong
2023-03-01 11:10:12 +08:00
parent 66efe61834
commit 081908bce3
6 changed files with 31 additions and 20 deletions

View File

@@ -347,7 +347,7 @@ func DeepClone[T any](src T) T {
func CopyProperties[T, U any](dst T, src U) (err error) {
defer func() {
if e := recover(); e != nil {
err = errors.New(fmt.Sprintf("%v", e))
err = fmt.Errorf("%v", e)
}
}()

View File

@@ -255,12 +255,12 @@ func ExampleDecodeByte() {
func ExampleDeepClone() {
type Struct struct {
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
Str string
Int int
Float float64
Bool bool
Nil interface{}
// unexported string
}
cases := []interface{}{
@@ -293,7 +293,7 @@ func ExampleDeepClone() {
// 1 false
// 0.1 false
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
// &{test 1 0.1 true <nil>} false
}
func ExampleCopyProperties() {
@@ -323,12 +323,18 @@ func ExampleCopyProperties() {
user := User{Name: "user001", Age: 10, Role: "Admin", Addr: Address{Country: "CN", ZipCode: "001"}, Hobbys: []string{"a", "b"}, salary: 1000}
employee1 := Employee{}
CopyProperties(&employee1, &user)
err := CopyProperties(&employee1, &user)
if err != nil {
return
}
employee2 := Employee{Name: "employee001", Age: 20, Role: "User",
Addr: Address{Country: "UK", ZipCode: "002"}, salary: 500}
CopyProperties(&employee2, &user)
err = CopyProperties(&employee2, &user)
if err != nil {
return
}
fmt.Println(employee1)
fmt.Println(employee2)

View File

@@ -259,12 +259,12 @@ func TestDeepClone(t *testing.T) {
// assert := internal.NewAssert(t, "TestDeepClone")
type Struct struct {
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
Str string
Int int
Float float64
Bool bool
Nil interface{}
// unexported string
}
cases := []interface{}{