Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetField doesn't appear to work #13

Open
eric-s-raymond opened this issue Nov 5, 2018 · 0 comments
Open

SetField doesn't appear to work #13

eric-s-raymond opened this issue Nov 5, 2018 · 0 comments

Comments

@eric-s-raymond
Copy link

I get the following trace:

`
--- FAIL: TestGetSetAttr (0.00s)
panic: reflect: call of reflect.Value.Elem on struct Value [recovered]
panic: reflect: call of reflect.Value.Elem on struct Value

goroutine 38 [running]:
testing.tRunner.func1(0xc4202544b0)
/usr/lib/go-1.10/src/testing/testing.go:742 +0x29d
panic(0x5d92e0, 0xc4201e9760)
/usr/lib/go-1.10/src/runtime/panic.go:502 +0x229
reflect.Value.Elem(0x5ef860, 0xc4202159e0, 0x99, 0xc4202159e0, 0x99, 0x20)
/usr/lib/go-1.10/src/reflect/value.go:775 +0x1b7
goreposurgeon.SetField(0x5ef860, 0xc4202159e0, 0x618dc0, 0x3, 0x5cb320, 0x64de00, 0x7, 0x61a0b5)
/home/esr/public_html/reposurgeon/src/goreposurgeon/goreposurgeon_test.go:1597 +0x6f
goreposurgeon.TestGetSetAttr(0xc4202544b0)
/home/esr/public_html/reposurgeon/src/goreposurgeon/goreposurgeon_test.go:1644 +0x1fa
testing.tRunner(0xc4202544b0, 0x632770)
/usr/lib/go-1.10/src/testing/testing.go:777 +0xd0
created by testing.(*T).Run
/usr/lib/go-1.10/src/testing/testing.go:824 +0x2e0
FAIL goreposurgeon 0.017s
`

That appears to relate to this line: structValue := reflect.ValueOf(obj).Elem()

If I remove the Elem() call, the function runs to completion but silently fails. e.g the field is not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant