Files
go-zero/example/fx/fx_test.go

34 lines
518 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
2020-10-17 12:51:46 +08:00
"fmt"
2020-07-26 17:09:05 +08:00
"testing"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/fx"
2020-07-26 17:09:05 +08:00
)
2020-10-17 12:51:46 +08:00
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))
})
}
2020-07-26 17:09:05 +08:00
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
})
}
}