This repository has been archived by the owner on Oct 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 693
Field.Set: use of reflect.Indirect #16
Comments
Hm but Here are the tests fro set https://github.com/fatih/structs/blob/master/field_test.go#L46 Could you add a test case that invalidates this test so I can be sure what the real problem is? |
I've forked your repository and added a test that fails. Basically: type Bar struct {
A string
}
type Foo struct {
B *Bar
}
foo := &Foo{
B: nil,
}
structInfo := structs.New(foo)
bar := &Bar {
A: "helloWorld",
}
err := structInfo.Field("B").Set(bar); err != nil {
fmt.Println(err) // Prints "field is not settable"
} |
Thanks! I'll look it into asap. |
fatih
added a commit
that referenced
this issue
Sep 9, 2014
Thanks for the case. I've added it to the test cases and fix the problem. As you said earlier there is no need to take the address as that would disallow to set it. 👍 |
Glad I could help :) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
Thanks for this useful package, but I have a question: why did you use reflect.Indirect when setting a field instead of using the value of the field itself? When setting pointers, it seems that it just does not work when using the value that the field points to.
The text was updated successfully, but these errors were encountered: