]> 127.0.0.1 Git - part/.git/commitdiff
add v0.28.0+20230812e3f3733
authorqydysky <qydysky@foxmail.com>
Sat, 12 Aug 2023 19:11:45 +0000 (03:11 +0800)
committerqydysky <qydysky@foxmail.com>
Sat, 12 Aug 2023 19:11:45 +0000 (03:11 +0800)
component/Component.go
component/Component_test.go

index 4e95f631a5c5aff0d7979b59290f04e6b87773df..e6775e36d4860c2803dc4c4337241deec5f1df53 100644 (file)
@@ -82,8 +82,8 @@ func Link(link map[string][]string) error {
        return Comp.Link(link)
 }
 
-func PKG(t any, sign ...string) (pkg string) {
-       pkg = reflect.TypeOf(t).PkgPath()
+func PKG[T any](sign ...string) (pkg string) {
+       pkg = reflect.TypeOf(*new(T)).PkgPath()
        for i := 0; i < len(sign); i++ {
                pkg += "." + sign[i]
        }
index a186d9baa04e088a2dc009926e888caacfe60580..b4b5c6a91f93d781e6cd23c2dd3e46ce67becc7a 100644 (file)
@@ -105,7 +105,7 @@ func Test3(t *testing.T) {
 
 func Test4(t *testing.T) {
        type empty struct{}
-       if pkg := PKG(empty{}, `1`, `2`); pkg != `github.com/qydysky/part/component.1.2` {
+       if pkg := PKG[empty](`1`, `2`); pkg != `github.com/qydysky/part/component.1.2` {
                t.Fatal(pkg)
        }
 }