Re: [go-nuts] Trying to add an `InterfaceOf` to `reflect` package but segmentation violation returned

2022-05-24 Thread Wenhua Shi
I'm really confusing. > That doesn't make sense to me. ifn and tfn need to refer to executable code. The code is copied from here https://github.com/golang/go/blob/0da4dbe2322eb3b6224df35ce3e9fc83f104762b/src/reflect/type.go#L2368 , why is it working here? > ifn and tfn need to refer to exe

Re: [go-nuts] Trying to add an `InterfaceOf` to `reflect` package but segmentation violation returned

2022-05-23 Thread Wenhua Shi
> return New(TypeOf("Interface {}")) Yes, it gives a string. It doesn't matter here since it's only an edge case. > What is the full stack trace Here it is, ``` === RUN TestInterfaceOf unexpected fault address 0xcb8090 fatal error: fault [signal SIGSEGV: segmentation violation code=0x2 add

[go-nuts] Trying to add an `InterfaceOf` to `reflect` package but segmentation violation returned

2022-05-23 Thread Wenhua Shi
I'm to create an object (whatever it is) satisfying certain interface dynamically. There's no way I can do it so I'm thinking maybe I can add a func in `reflect` package to cover my need. The `reflect.StructOf` func creates a struct type but without adding methods which gives a good example. I