pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.68k stars 208 forks source link

Panic when parsing '0' using parseFloat #886

Closed ocean2811 closed 11 months ago

ocean2811 commented 11 months ago

Describe the bug Panic when parsing '0'(number without decimals) as a float type.

To Reproduce

const file = `foo = 0` // read from .toml file

type Toml struct {
    Foo float64 `toml:"foo"`
}

t := &Toml{}
err := toml.Unmarshal([]byte(file), t)
fmt.Println(t, err)
return

Expected behavior Normal output of TOML structure contents.

Versions