Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Decoding array of slices causes panic #340

Open
@nolag

Description

@nolag

The simplest way I can re-do it is below. It causes a panic [1]

package main

import (
	"fmt"
	"github.com/mitchellh/mapstructure"
)

type Foo struct {
	B [2][]byte
}

func main() {
	f := &Foo{}
	if err := mapstructure.Decode(map[string]interface{}{"B": [2][]byte{{1, 2}, {3, 4}}}, &f); err != nil {
		panic(err)
	}
	fmt.Println(f.B)
}

[1]

panic: runtime error: comparing uncomparable type [2][]uint8

goroutine 1 [running]:
github.com/mitchellh/mapstructure.(*Decoder).decodeArray(0x1400006e1f8, {0x1012344ac, 0x1}, {0x10129cfe0, 0x14000421d10}, {0x10129cfe0?, 0x14000421cb0?, 0x1009eff8c?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1164 +0x1f8
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x1012344ac, 0x1}, {0x10129cfe0?, 0x14000421d10?}, {0x10129cfe0?, 0x14000421cb0?, 0x10095c388?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:490 +0x1b8
github.com/mitchellh/mapstructure.(*Decoder).decodeStructFromMap(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?, 0x100964b10?}, {0x1012e9e80?, 0x14000421cb0?, 0x140005cdb18?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1411 +0x718
github.com/mitchellh/mapstructure.(*Decoder).decodeStruct(0x140005cdc48?, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x1012e9e80?, 0x14000421cb0?, 0x6050f655bb53ef15?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1235 +0x3ec
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x1012e9e80?, 0x14000421cb0?, 0x100964b10?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:482 +0x218
github.com/mitchellh/mapstructure.(*Decoder).decodePtr(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380, 0x14000421ce0}, {0x101270c40?, 0x1400006e1e8?, 0x101b84130?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:1052 +0x3b8
github.com/mitchellh/mapstructure.(*Decoder).decode(0x1400006e1f8, {0x0, 0x0}, {0x1012c7380?, 0x14000421ce0?}, {0x101270c40?, 0x1400006e1e8?, 0x10138a120?})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:486 +0x1e8
github.com/mitchellh/mapstructure.(*Decoder).Decode(0x1400006e1f8, {0x1012c7380, 0x14000421ce0})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:417 +0xb8
github.com/mitchellh/mapstructure.Decode({0x1012c7380, 0x14000421ce0}, {0x101280080?, 0x1400006e1e8})
        <user>//go/pkg/mod/github.com/mitchellh/[email protected]/mapstructure.go:317 +0x8c
main.main()
        <user>//go/src/playground/entry.go:14 +0x144

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions