This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
Closed
Description
To reproduce, modify the TestWalk_Struct test to this
func TestWalk_Struct(t *testing.T) {
w := new(TestStructWalker)
type S struct {
Foo string
Bar string
Baz *int
}
data := &S{
Foo: "foo",
Bar: "bar",
}
err := Walk(data, w)
if err != nil {
t.Fatalf("err: %s", err)
}
expected := []string{"Foo", "Bar", "Baz"}
if !reflect.DeepEqual(w.Fields, expected) {
t.Fatalf("bad: %#v", w.Fields)
}
}
Then run go test and observe the output:
--- FAIL: TestWalk_Struct (0.00s)
panic: unsupported type: invalid [recovered]
panic: unsupported type: invalid
goroutine 14 [running]:
testing.func·006()
c:/go/src/testing/testing.go:441 +0x188
github.com/mitchellh/reflectwalk.walk(0x0, 0x0, 0x0, 0x543c60, 0xc0820049a0, 0x0, 0x0)
C:/gopath/src/github.com/mitchellh/reflectwalk/reflectwalk.go:159 +0x478
github.com/mitchellh/reflectwalk.walkStruct(0x548c20, 0xc082060360, 0xd9, 0x543c60, 0xc0820049a0, 0x0, 0x0)
C:/gopath/src/github.com/mitchellh/reflectwalk/reflectwalk.go:294 +0x451
github.com/mitchellh/reflectwalk.walk(0x548c20, 0xc082060360, 0xd9, 0x543c60, 0xc0820049a0, 0x0, 0x0)
C:/gopath/src/github.com/mitchellh/reflectwalk/reflectwalk.go:148 +0x5b1
github.com/mitchellh/reflectwalk.Walk(0x500a40, 0xc082060360, 0x543c60, 0xc0820049a0, 0x0, 0x0)
C:/gopath/src/github.com/mitchellh/reflectwalk/reflectwalk.go:82 +0x13e
github.com/mitchellh/reflectwalk.TestWalk_Struct(0xc0820105a0)
C:/gopath/src/github.com/mitchellh/reflectwalk/reflectwalk_test.go:369 +0xd4
testing.tRunner(0xc0820105a0, 0x62cd98)
c:/go/src/testing/testing.go:447 +0xc6
created by testing.RunTests
c:/go/src/testing/testing.go:555 +0xa92
Metadata
Assignees
Labels
No labels