-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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.Elem() inconsistency betwen go1.4.3 and go.15 #12954
Comments
Distilled, This doesn't violate Go 1 compatibility guidelines, which says The Go specification tries to be explicit about most properties of the language, but there are some aspects that are undefined. Programs that depend on such unspecified behavior may break in future releases. In Go 1.4.3 Note that |
Actually, I admit it was a breaking change because fmt specification essentially changed: the rule
applied to |
The change is documented in https://golang.org/go1.5.html. I don't consider it to be a Go 1 compatibility breaking change: if we changed reflect.Value.String that wouldn't be a breaking change either. Breaking user types would be a breaking change. The handling of library defined types is up to the library. |
Use elem.Interface() to get the value instead of implicitly relying on fmt.*Printf("%v", elem) due to a discrepenacy between Go1.5 and < Go1.5 ie golang/go#12954
Alright, thank you folks for taking a look at this. My way around it was to invoke ".Interface()" - fmt.Sprintf("%v", elem)
+ fmt.Sprintf("%v", elem.Interface()) and that produces the desired result between go 1.5 and 1.4.3. |
In some code whose struct
I perform some value extraction by json tag and fill in a fresh pushCmd value with a mix of already defined values from a resource configuration and those already entered in the from value. However, running the exact same program http://play.golang.org/p/4NRzI-ejuc on go1.4.3 and then on go.1.5 gives different results
The code example and results are at https://github.com/odeke-em/bugs/tree/master/golang/reflect-inconsistency
The text was updated successfully, but these errors were encountered: