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

reflect.Value.IsValid's doc is error #40892

Closed
j2gg0s opened this issue Aug 19, 2020 · 0 comments
Closed

reflect.Value.IsValid's doc is error #40892

j2gg0s opened this issue Aug 19, 2020 · 0 comments

Comments

@j2gg0s
Copy link
Contributor

j2gg0s commented Aug 19, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you expect to see?

reflect.Value.IsValid's document show: It returns false if v is the zero Value.
But, Its behavior does not conform to the documentation.

Run this test and get

func TestReflectValue(t *testing.T) {
        var x int
        x = 0

        if reflect.ValueOf(x).IsValid() {
                t.Errorf("Value of int with zero value should not be valid")
        }
}
--- FAIL: TestReflectValue (0.00s)
    reflect_test.go:13: Value of int with zero value should not be valid

My understanding is wrong? Or document is wrong?

@j2gg0s j2gg0s closed this as completed Aug 19, 2020
@golang golang locked and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants