Skip to content

Panic with *bool field and default tag #92

@jmattheis

Description

@jmattheis

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/configor@v1.2.2/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/configor@v1.2.2/utils.go:415 +0x3f8
github.com/jinzhu/configor.(*Configor).Load(0xc0000141a0, {0x542fa0, 0xc000070058}, {0x0, 0x0, 0x0})
        /home/jm/go/pkg/mod/github.com/jinzhu/configor@v1.2.2/configor.go:92 +0x13c
main.main()
        /tmp/test/main.go:17 +0x7d

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions