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

@j2gg0s 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 Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.