I have 2 different packages(pkg1, pkg2), in first i have code that calls function from another package
file#1
package pkg1
import "pkg2"
import "reflect"
type User struct {
name string
...
}
func main() {
fmt.Println(reflect.TypeOf((*User)(nil)) //=> *User
pkg2.RegisterStruct(reflect.TypeOf((*User)(nil))
}
file#2
package pkg2
import "reflect"
func RegisterStruct(u interface{}) {
fmt.Println(u) //=> *reflect.rtype
}
Why type was reflect.rtype instead of *User ? And how do i correctly pass type to another pkg?
Aucun commentaire:
Enregistrer un commentaire