Skip to content

bug: Cleanenv ignore environment variable when using pointer #147

Open
@afifurrohman-id

Description

Reproduceable steps:

  • config.yaml
foo: hello
  • main.go
package main

import (
	"fmt"

	"github.com/ilyakaznacheev/cleanenv"
)

type (
	Config struct {
		Foo *string `env-required:"true" yaml:"foo" env:"FOO"`
	}

)

func main() {
	cfg := new(Config)
	_ = cleanenv.ReadConfig("config.yaml", cfg)
	cleanenv.ReadEnv(cfg)

	fmt.Println(*cfg.Foo)
}
export FOO=bar

it will print "hello" instead of bar

is this limitation of reflection??

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