You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/example/fx/fx_test.go

34 lines
518 B
Go

4 years ago
package main
import (
4 years ago
"fmt"
4 years ago
"testing"
"github.com/tal-tech/go-zero/core/fx"
4 years ago
)
4 years ago
func TestFxSplit(t *testing.T) {
fx.Just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Split(4).ForEach(func(item interface{}) {
vals := item.([]interface{})
fmt.Println(len(vals))
})
}
4 years ago
func BenchmarkFx(b *testing.B) {
type Mixed struct {
Name string
Age int
Gender int
}
for i := 0; i < b.N; i++ {
var mx Mixed
fx.Parallel(func() {
mx.Name = "hello"
}, func() {
mx.Age = 20
}, func() {
mx.Gender = 1
})
}
}