Giter Club home page Giter Club logo

Comments (4)

nerg4l avatar nerg4l commented on July 17, 2024 9

If I understand @lesichkovm correctly he would like to have a function which simplifies the following:

val, ok := os.LookupEnv("KEY")
if !ok {
  val = "DEFAULT_VAL"
}

Instead of the above code you could write this:

val := godotenv.Env("KEY", "DEFAULT_VAL")

from godotenv.

D-sense avatar D-sense commented on July 17, 2024

@lesichkovm, I think there is a similar logic provided already. When you call the Load(filenames ...string) or Overload(filenames ...string), it first calls on filenamesOrDefault(filenames); If "filenames" is empty, a fallback is provided. This fallback expects to find ".env" file in the root folder.

from godotenv.

lesichkovm avatar lesichkovm commented on July 17, 2024

@D-sense it is not about loading files, but a helper function to check if an environmental variable exists:

myVar := Env("MYENV", "DEFAULT_IF_NOT_SET")

from godotenv.

D-sense avatar D-sense commented on July 17, 2024

@lesichkovm , please ignore the tagging of the PR. It was a mistake (I didn’t mean to tag it here).

On the point you raised, except I still haven’t gotten your point well enough, I think the existing logic already caters for that need (as outlined in my earlier response). I might be wrong though.

from godotenv.

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.