1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-23 13:52:26 +08:00

fix: fix example function bug in function package

This commit is contained in:
dudaodong
2023-01-08 21:09:41 +08:00
parent bce3641ec6
commit d95a7c6101
2 changed files with 6 additions and 14 deletions

View File

@@ -145,14 +145,6 @@ func unsafeInvokeFunc(fn any, args ...any) []reflect.Value {
return fv.Call(params) return fv.Call(params)
} }
func functionValue(function any) reflect.Value {
v := reflect.ValueOf(function)
if v.Kind() != reflect.Func {
panic(fmt.Sprintf("Invalid function type, value of type %T", function))
}
return v
}
func mustBeFunction(function any) { func mustBeFunction(function any) {
v := reflect.ValueOf(function) v := reflect.ValueOf(function)
if v.Kind() != reflect.Func { if v.Kind() != reflect.Func {

View File

@@ -108,21 +108,21 @@ func ExampleDebounced() {
} }
func ExampleSchedule() { func ExampleSchedule() {
var result []string count := 0
appendFn := func(s string) { increase := func() {
result = append(result, s) count++
} }
stop := Schedule(1*time.Second, appendFn, "*") stop := Schedule(1*time.Second, increase)
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
close(stop) close(stop)
fmt.Println(result) fmt.Println(count)
// Output: // Output:
// [* * *] // 3
} }
func ExamplePipeline() { func ExamplePipeline() {