Skip to content

reflect: behaviour change in 1.4 #9893

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

Closed
amir opened this issue Feb 16, 2015 · 2 comments
Closed

reflect: behaviour change in 1.4 #9893

amir opened this issue Feb 16, 2015 · 2 comments

Comments

@amir
Copy link
Contributor

amir commented Feb 16, 2015

Reading 1.4 Release Notes I can'd find references to the following change of behaviour in 1.4:

package main

import (
    "fmt"
    "reflect"
)

func main() {
    var Ttl float32
    var Time int64
    intZeroValue := reflect.Zero(reflect.ValueOf(Time).Type())
    floatZeroValue := reflect.Zero(reflect.ValueOf(Ttl).Type())

    fmt.Printf("%t\n%t\n", intZeroValue == reflect.ValueOf(Time), floatZeroValue == reflect.ValueOf(Ttl))
}

1.3 prints:

true
true

When 1.4 prints:

false
false
@mattn
Copy link
Member

mattn commented Feb 16, 2015

Dup #9504 ?

@amir
Copy link
Contributor Author

amir commented Feb 16, 2015

Using .Interface() seems to do the trick.

@amir amir closed this as completed Feb 16, 2015
@mikioh mikioh changed the title reflect behaviour change in 1.4 reflect: behaviour change in 1.4 Feb 16, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

3 participants