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
Try the following code:
package main import "github.com/BurntSushi/toml" import "log type Q struct { Test []string } func main() { q := Q{Test: []string{}} _, err := toml.Decode(`Test = ["test"]`, &q) if err != nil { log.Fatal(err) } }
This results in a panic:
panic: reflect: slice index out of range goroutine 1 [running]: reflect.Value.Index(0x6c1b60, 0x12658d80, 0xd7, 0x0, 0x0, 0x0, 0x0) c:/go/src/reflect/value.go:818 +0x10f github.com/BurntSushi/toml.(*MetaData).unifySliceArray(0x12652ba0, 0x6c0d60, 0x12658dd0, 0x57, 0x6c1b60, 0x12658d80, 0xd7, 0x0, 0x0) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:321 +0xde github.com/BurntSushi/toml.(*MetaData).unifySlice(0x12652ba0, 0x6c0d60, 0x12658dd0, 0x6c1b60, 0x12658d80, 0xd7, 0x0, 0x0) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:314 +0x1b4 github.com/BurntSushi/toml.(*MetaData).unify(0x12652ba0, 0x6c0d60, 0x12658dd0, 0x6c1b60, 0x12658d80, 0xd7, 0x0, 0x0) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:206 +0xb11 github.com/BurntSushi/toml.(*MetaData).unifyStruct(0x12652ba0, 0x6cc160, 0x126543c0, 0x6d3e80, 0x12658d80, 0xd9, 0x0, 0x0) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:252 +0x65a github.com/BurntSushi/toml.(*MetaData).unify(0x12652ba0, 0x6cc160, 0x126543c0, 0 x6d3e80, 0x12658d80, 0xd9, 0x0, 0x0) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:200 +0xb9f github.com/BurntSushi/toml.Decode(0x7adf28, 0xf, 0x6bcbe0, 0x12658d80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) %GOPATH%/src/github.com/BurntSushi/toml/decode.go:114 +0x1c5 main.NewStaticContext(0x12655947, 0xa, 0x12656900, 0x0, 0x0, 0x0) ...
This is only caused when the Test field is initialized to an empty slice.
Test
If Test is nil or has at least one element, Decode works as expected.
nil
Decode
The text was updated successfully, but these errors were encountered:
Fix ToMap conversion of array of tables (BurntSushi#83)
06484b6
No branches or pull requests
Try the following code:
This results in a panic:
This is only caused when the
Test
field is initialized to an empty slice.If
Test
isnil
or has at least one element,Decode
works as expected.The text was updated successfully, but these errors were encountered: