Skip to content
New issue

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

Panic with *bool field and default tag #92

Open
jmattheis opened this issue Nov 15, 2024 · 0 comments
Open

Panic with *bool field and default tag #92

jmattheis opened this issue Nov 15, 2024 · 0 comments
Assignees

Comments

@jmattheis
Copy link

Reproducible Example

package main

import (
	"os"
	"github.com/jinzhu/configor"
)

type Config struct {
	Enabled *bool `default:"false"`
}

func main() {
	os.Setenv("ENV_ENABLED", "false")

	c := Config{}
	configor.New(&configor.Config{ENVPrefix: "ENV"}).Load(&c)
}

Description

Panics with

panic: reflect.Set: value of type bool is not assignable to type *bool

goroutine 1 [running]:
reflect.Value.assignTo({0x5480a0?, 0x67c7e0?, 0xb?}, {0x5700af, 0xb}, 0x5436a0, 0x0)
        /usr/lib/go/src/reflect/value.go:3358 +0x299
reflect.Value.Set({0x5436a0?, 0xc000070058?, 0x2?}, {0x5480a0?, 0x67c7e0?, 0x5436a0?})
        /usr/lib/go/src/reflect/value.go:2313 +0xe6
github.com/jinzhu/configor.(*Configor).processTags(0xc0000141a0, {0x542fa0?, 0xc000070058?}, {0xc0000141e0, 0x1, 0x1})
        /home/jm/go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:305 +0xb88
github.com/jinzhu/configor.(*Configor).load(0xc0000141a0, {0x542fa0, 0xc000070058}, 0x0, {0x0?, 0xc0000b3ed0?, 0x40d205?})
        /home/jm/go/pkg/mod/github.com/jinzhu/[email protected]/utils.go:415 +0x3f8
github.com/jinzhu/configor.(*Configor).Load(0xc0000141a0, {0x542fa0, 0xc000070058}, {0x0, 0x0, 0x0})
        /home/jm/go/pkg/mod/github.com/jinzhu/[email protected]/configor.go:92 +0x13c
main.main()
        /tmp/test/main.go:17 +0x7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants