You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Marshalling a struct with a Float value as an integer returns output which when Unmarshalled back into the struct, returns an error toml: cannot store TOML integer into a Go float32.
To Reproduce
package main
import (
"fmt"
"github.com/pelletier/go-toml/v2"
)
type Foo struct {
Float float32
}
func main() {
foo := Foo{
Float: 1,
}
b, err := toml.Marshal(foo)
if err != nil {
fmt.Println(err)
}
fmt.Println(string(b))
// Output: Float = 1
foo2 := Foo{}
err = toml.Unmarshal(b, &foo2)
if err != nil {
fmt.Println(err)
// Output: toml: cannot store TOML integer into a Go float32
}
fmt.Println(foo2)
}
Output
Float = 1
toml: cannot store TOML integer into a Go float32
{0}
ExpectedOutput
Float = 1.0
{1}
Expected behavior
It should be able to marshal an struct with a integer as a float, and unmarshal it back into the struct.
Versions
go-toml: v2.0.0-beta.3
go: version 1.16
operating system: macOS
Additional context
Add any other context about the problem here that you think may help to diagnose.
The text was updated successfully, but these errors were encountered:
Describe the bug
Marshalling a struct with a
Float
value as an integer returns output which when Unmarshalled back into the struct, returns an errortoml: cannot store TOML integer into a Go float32
.To Reproduce
Output
ExpectedOutput
Expected behavior
It should be able to marshal an struct with a integer as a float, and unmarshal it back into the struct.
Versions
Additional context
Add any other context about the problem here that you think may help to diagnose.
The text was updated successfully, but these errors were encountered: