-
Notifications
You must be signed in to change notification settings - Fork 183
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
If I use koanf.Set to set a nil struct pointer, it panics when I try to get the value by koanf.Get
This may not be a typical use case, but if Set is allowed to set a nil struct pointer, it seems like a bug Get cannot get the corresponding value from the same path.
To Reproduce
package main
import (
"github.com/knadh/koanf/v2"
)
type Test struct{}
func main() {
var t *Test
k := koanf.New(".")
k.Set("a", t)
k.Get("a") // panic: reflect: call of reflect.Value.Set on zero Value
}
Expected behavior
No panic and get the nil struct pointer
Please provide the following information):
- OS: linux
- Koanf Version: 2.3.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working