We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Example code:
package main import ( "fmt" "math" "gopkg.in/v2/yaml" ) type A struct { F float64 } func main() { f32 := A{math.MaxFloat32} f64 := A{math.MaxFloat64} y32, err := yaml.Marshal(f32) if err != nil { fmt.Printf("%v\n", err) } y64, err := yaml.Marshal(f64) if err != nil { fmt.Printf("%v\n", err) } fmt.Printf("Should contain %v: %v", math.MaxFloat32, string(y32)) fmt.Printf("Should contain %v: %v", math.MaxFloat64, string(y64)) } // output: Should contain 3.4028234663852886e+38: f: 3.4028235e+38 Should contain 1.7976931348623157e+308: f: .inf
Seems to be related to this line of code: https://github.com/go-yaml/yaml/blob/v2/encode.go#L285
The text was updated successfully, but these errors were encountered:
I have just tested this code and it seems to work correctly.
lab@ubu1:~$ more f.go package main import ( "fmt" "math" "gopkg.in/v2/yaml" ) type A struct { F float64 } func main() { f32 := A{math.MaxFloat32} f64 := A{math.MaxFloat64} y32, err := yaml.Marshal(f32) if err != nil { fmt.Printf("%v\n", err) } y64, err := yaml.Marshal(f64) if err != nil { fmt.Printf("%v\n", err) } fmt.Printf("Should contain %v: %v", math.MaxFloat32, string(y32)) fmt.Printf("Should contain %v: %v", math.MaxFloat64, string(y64)) } lab@ubu1:~$ go run f.go Should contain 3.4028234663852886e+38: f: 3.4028234663852886e+38 Should contain 1.7976931348623157e+308: f: 1.7976931348623157e+308 lab@ubu1:~$
Sorry, something went wrong.
No branches or pull requests
Example code:
Seems to be related to this line of code: https://github.com/go-yaml/yaml/blob/v2/encode.go#L285
The text was updated successfully, but these errors were encountered: