Hi, all:
I'm writing a little fuzz tool for struct using reflect package, and
came across the following case, but didn't find any way to solve it
type TestStruct struct {
a *int // unexported nil ptr field, how to modify it?
b int // unexported not ptr field, can be modified using
reflect.NewAt
C *int // exported nil ptr field, can be modified using
reflect.New and value.Set
}
ts := &TestStruct {} // a is nil ptr and not exported
fieldA := reflect.ValueOf(ts).Elem().Field(0)
// how to modify the value of a using the reflect value fieldA?
here is the full code fuzz.go
<https://gist.github.com/feilengcui008/1ef29539bf7ccab5993c796ca2ddf227#file-fuzz-go-L44>
Hope to get some advice, thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.