Comments (8)
A good question, let me try and figure out
- What we do
- What we should do (ie what does the ruby lib do)
from godotenv.
~/Projects/dotenvtest ruby test.rb
xTvDqw
foo$bar
123value
~/Projects/dotenvtest BAR=other ruby test.rb
xTvDqw
foo$bar
123other
~/Projects/dotenvtest vim test.go
~/Projects/dotenvtest go run test.go
xTvDqw7
foo\
123value
~/Projects/dotenvtest BAR=other go run test.go
xTvDqw7
foo\
123value
Environment variables should take preference (but don't), though there will probably be some edge cases in load vs overload.
Guess there's a 1.3.1 coming soon 😄
from godotenv.
Had this discussion with a coworker and he told me the same.
Each time a .env is loaded the prior takes precedence.
The rationale being
- secrets go in memory only
- .env.{dev,testing,staging,prod) have the endpoints go same tier services
- .env (local) has personal preference for local dev and doesn’t get committed
from godotenv.
Thanks for looking into that and I look forward to the new version
from godotenv.
poke => v1.3.1 with precedence fixes?
from godotenv.
Hey sorry - hell of a hectic week as a sole startup founder and haven't been able to jump straight on this. Will try today or tomorrow. PRs always welcome if you need to hurry it along more than that.
from godotenv.
I starting digging into the code and it looked as if everything was in order.
I ran a test to be sure and it seems to me that all is working as it should:
test.go
:
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
)
func main() {
os.Setenv("QUX", "nowyouseeme")
godotenv.Load()
godotenv.Load("second.env", "third.env")
fmt.Printf("FOO=%s (%s)\n", os.Getenv("FOO"), "\"nowyouseeme\"")
fmt.Printf("BAR=%s (%s)\n", os.Getenv("BAR"), "\"nowyouseeme\"")
fmt.Printf("BAZ=%s (%s)\n", os.Getenv("BAZ"), "\"nowyouseeme\"")
fmt.Printf("QUX=%s (%s)\n", os.Getenv("QUX"), "\"nowyouseeme\"")
fmt.Printf("QUUX=%s (%s)\n", os.Getenv("QUUX"), "\"\"")
}
.env
:
FOO=nowyouseeme
QUX=NOWYOUDONT
second.env
:
FOO=NOWYOUDONT
BAR=nowyouseeme
third.env
:
FOO=NOWYOUDONT2
BAR=NOWYOUDONT
BAZ=nowyouseeme
go run test.go
:
# actual test results vs hard-coded expectation
FOO=nowyouseeme ("nowyouseeme")
BAR=nowyouseeme ("nowyouseeme")
BAZ=nowyouseeme ("nowyouseeme")
QUX=nowyouseeme ("nowyouseeme")
QUUX= ("")
FOO=DOUBLECHECKING go run test.go
:
# result for FOO is preferring the existing environment, as expected
FOO=DOUBLECHECKING ("nowyouseeme")
BAR=nowyouseeme ("nowyouseeme")
BAZ=nowyouseeme ("nowyouseeme")
QUX=nowyouseeme ("nowyouseeme")
QUUX= ("")
from godotenv.
Here are some suggestions for updating the REAME: #60
from godotenv.
Related Issues (20)
- Create ARM release for godotenv binary? HOT 3
- godotenv is "complete" and not accepting feature requests HOT 1
- Expanding variable value
- expanding command line interface or linking to sister project
- How to set default value in yaml file
- dotenv does not report an error if file does not exist HOT 2
- Variables in dotenv file starting with capital letter when they shouldn't
- Bugs in parser around unquoted whitespace and newlines in v1.5.0 HOT 10
- `-` is not supported in the key from version 1.5 but is supported in 1.4. Can we please take a look here ? This is a very basic use case. HOT 2
- Variable in the form `VAR="${VAR:-default}"` does not parse correctly
- Getting double quotes in values in env file HOT 2
- .env: no such file or directory HOT 5
- Inline comments in .env breaks builds for linux amd64
- How tu use godotenv when testing implemented? HOT 2
- Failed to parse when yaml document delimiter is present
- LICENCE file is mispelled HOT 1
- There was a problem using the command "go install github.com/joho/godotenv/cmd/godotenv@latest" HOT 1
- inconsisting case handling across different OS HOT 1
- extractVarValue assumes a quote is escaped if a backslash precedes it, even if the backslash is escaped
- (possible) bug in parser right-trimming escaped quotes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godotenv.