添加反射

This commit is contained in:
JACKYMYPERSON
2025-08-30 05:53:10 +08:00
parent 2cf33460f8
commit ee1bbb59a4
2 changed files with 22 additions and 9 deletions

20
main.go
View File

@@ -1,10 +1,9 @@
package main package main
import ( import (
"goLearn/connectPool"
"goLearn/model" "goLearn/model"
"goLearn/reflect"
"sync" "sync"
"time"
) )
var Ch = make(chan model.Task, 3) var Ch = make(chan model.Task, 3)
@@ -34,17 +33,20 @@ func main() {
//--------------------- //---------------------
donetitle := make(chan struct{}) //donetitle := make(chan struct{})
//
connectPool.ConnectPool(donetitle) //connectPool.ConnectPool(donetitle)
//
time.Sleep(5 * time.Second) //time.Sleep(5 * time.Second)
close(donetitle) //close(donetitle)
defer connectPool.DisconnectPool() //defer connectPool.DisconnectPool()
//------------------ //------------------
//ctx := context.WithValue(context.Background(), "value", model.Task{Id: "1", Content: "1"}) //ctx := context.WithValue(context.Background(), "value", model.Task{Id: "1", Content: "1"})
//goroutine.Runtask(ctx) //goroutine.Runtask(ctx)
reflect.FuncReflect(make([]int, 3))
} }
// //

11
reflect/reflect.go Normal file
View File

@@ -0,0 +1,11 @@
package reflect
import (
"fmt"
"reflect"
)
func FuncReflect(inter interface{}) {
typein := reflect.TypeOf(inter).Elem()
fmt.Println("typein:", typein)
}