Skip to content

panic: slice of struct pointers #370

@DeadLockStarve

Description

@DeadLockStarve

Version

1.67.0

Describe the bug

The library doesn't treat correctly slices of struct pointers

To reproduce

package main

import (
	"log"

	"gopkg.in/ini.v1"
)

const iniData = `[Peer]
PublicKey    = pubClientKey
PresharedKey = psKey
AllowedIPs   = 10.2.0.2/32,fd00:2::2/128

[Peer]
PublicKey    = pubClientKey2
PresharedKey = psKey2
AllowedIPs   = 10.2.0.3/32,fd00:2::3/128
`

type Peer struct {
	PublicKey    string
	PresharedKey string
	AllowedIPs   []string `delim:","`
}

type Config struct {
	Peers []*Peer `ini:"Peer,nonunique"`
}

func main() {
	cfgFile, err := ini.LoadSources(ini.LoadOptions{AllowNonUniqueSections: true}, []byte(iniData))
	if err != nil {
		log.Fatal(err)
	}

	cfg := new(Config)
	if err := cfgFile.MapTo(&cfg); err != nil {
		log.Fatal(err)
	}
}

Expected behavior

Should unmarshal correctly, panics instead

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions