GithubHelp home page GithubHelp logo

Comments (5)

kz avatar kz commented on August 18, 2024

I ran into this problem too, and I notice Kelsey Hightower's envconfig package also does not check whether the field you are attempting to set is unexported. Assuming there is no other case where a developer would set the env tag on an unexported field other than intending for that field to be exported, should unexported fields with env tags throw errors? (https://groups.google.com/g/golang-nuts/c/i50jwcgHAcs)

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on August 18, 2024

This is a standard and expected behavior of Golang - library cannot read unexported fields from another package.

The expected behavior it that such fields will be ignored.

from cleanenv.

saddit avatar saddit commented on August 18, 2024

@ilyakaznacheev

panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

goroutine 1 [running]:
reflect.valueInterface({0x95f8a0?, 0xc00055c248?, 0xabea8f?}, 0xa?)
        E:/software/dev_core/go1.18.1/src/reflect/value.go:1441 +0xd8
reflect.Value.Interface(...)
        E:/software/dev_core/go1.18.1/src/reflect/value.go:1430
github.com/ilyakaznacheev/cleanenv.readStructMetadata({0x9c7900?, 0xc00055c1c0?})

        E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:274 +0x771
github.com/ilyakaznacheev/cleanenv.readEnvVars({0x9c7900, 0xc00055c1c0}, 0x0)

        E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:333 +0x45
github.com/ilyakaznacheev/cleanenv.ReadConfig({0xace493?, 0xc00041f9a8?}, {0x9c7900, 0xc00055c1c0})


        E:/text/code-project/GolangProject/pkg/mod/github.com/ilyakaznacheev/[email protected]/cleanenv.go:95 +0x48

It doesn't skip unexport field

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on August 18, 2024

@838239178 can you provide a code example, please?

from cleanenv.

ilyakaznacheev avatar ilyakaznacheev commented on August 18, 2024

Better create a new issue with an example and detailed error and environment description. Thanks

from cleanenv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.