1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +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{}{

View File

@@ -17,7 +17,7 @@ type mapNode struct {
next *mapNode
}
//HashMap implements a hash map
// HashMap implements a hash map
type HashMap struct {
capacity uint64
size uint64

View File

@@ -19,11 +19,15 @@ func ExampleContext() {
return errors.New("error occurs")
}
Retry(increaseNumber,
err := Retry(increaseNumber,
RetryDuration(time.Microsecond*50),
Context(ctx),
)
if err != nil {
return
}
fmt.Println(number)
// Output:

View File

@@ -64,6 +64,7 @@ func Generate[T any](generator func() func() (item T, ok bool)) stream[T] {
var zeroValue T
for next, item, ok := generator(), zeroValue, true; ok; {
item, ok = next()
if ok {
source = append(source, item)
@@ -98,7 +99,7 @@ func FromRange[T constraints.Integer | constraints.Float](start, end, step T) st
}
l := int((end-start)/step) + 1
source := make([]T, l, l)
source := make([]T, l)
for i := 0; i < l; i++ {
source[i] = start + (T(i) * step)
@@ -160,7 +161,7 @@ func (s stream[T]) Filter(predicate func(item T) bool) stream[T] {
// Map returns a stream consisting of the elements of this stream that apply the given function to elements of stream.
func (s stream[T]) Map(mapper func(item T) T) stream[T] {
source := make([]T, s.Count(), s.Count())
source := make([]T, s.Count())
for i, v := range s.source {
source[i] = mapper(v)