"context"
"errors"
"maps"
+ "reflect"
"sync/atomic"
psync "github.com/qydysky/part/sync"
return Comp.Link(link)
}
+func PKG(sign ...string) (pkg string) {
+ type empty struct{}
+ pkg = reflect.TypeOf(empty{}).PkgPath()
+ for i := 0; i < len(sign); i++ {
+ pkg += "." + sign[i]
+ }
+ return
+}
+
var Comp *components = NewComp()
)
func Test1(t *testing.T) {
+ Comp = NewComp()
Put(`1`, func(ctx context.Context, ptr *int) error {
if *ptr > 1 {
return nil
}
func TestDot(t *testing.T) {
+ Comp = NewComp()
Put[int](`1`, func(ctx context.Context, ptr *int) error {
if *ptr == 1 {
return nil
}
func Test3(t *testing.T) {
+ Comp = NewComp()
sumup := func(ctx context.Context, ptr *int) error {
return nil
}
}
}
+func Test4(t *testing.T) {
+ if pkg := PKG(`1`, `2`); pkg != `github.com/qydysky/part/component.1.2` {
+ t.Fatal(pkg)
+ }
+}
+
func Benchmark2(b *testing.B) {
for i := 0; i < b.N; i++ {
Put[int](strconv.Itoa(i), func(ctx context.Context, ptr *int) error {