Comments (4)
Hi @bnewbold.
My idea would be a bit different that you expect. I would like to discuss it before making PR with changes .
I believe .env
file will be used only in development environment and make
file be great tool here.
It maybe sound extreme but I would suggest to move environment variables setup to Makefile
. It could be done but adding
ifneq (,$(wildcard ./.env))
include .env
export
endif
to the top of Makefile
.
Making this change will solve the issue with GOLOG_LOG_LEVEL
, cleanup the copy and paste code below from each command and allow to remove godotenv
from the project
// only try dotenv if it exists
if _, err := os.Stat(".env"); err == nil {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
}
What do you think about it?
from indigo.
I've never tried parsing a .env
from a Makefile. Does it work? Does it parse the file as Makefile syntax? I'm not sure if that is a problem or not, might be fine.
The Makefile on it's own wouldn't help with things like go run
or use of fakermaker and gosky CLIs, which I at least run frequently with different args and rely on .env
for basic auth and config. It is possible to use a separate wrapper command like dotenv
(apt get install dotenv
on Debian), or we could have CLI tools load .env
and service commands not.
It is a bit weird to have the daemon processes look for .env
on every invocation, but I also don't think it is causing any problems. I think the GOLOG_LOG_LEVEL
issue is probably a trivial one-line fix, I just haven't gotten around to testing it. So, overall, feel this is low priority.
from indigo.
I found a nice fix using import _ "github.com/joho/godotenv/autoload"
, which reduces boilerplate and works at package init()
time, so it can out-race the logging setup. It does still look for a .env
always, but i'm going to prefer that fix for now.
from indigo.
@bnewbold It's the great solution. Please take a look on PR.
from indigo.
Related Issues (20)
- brainstorm: package refactoring HOT 1
- handling typed identifier strings HOT 1
- legacy blob parsing broken
- lexgen: optional query params for concrete types (bool, integer)
- cborgen: support nullable booleans
- lexgen+cborgen: support arrays-of-arrays
- cborgen: support for 'float' types
- gosky: bsky.RepoGetRecord return 400 Bad Request
- indigo: followsAddCmd return XRPC ERROR 400: 400 Bad Request HOT 2
- How do we use ./cmd/gosky to do things like log in and post? HOT 1
- Some of my posts don't decode HOT 8
- HACKING.md needs to be updated
- pipeline event stream playback
- atproto.RepoDescribeRepo fails with a decode error for did:plc:wflozfzpewefv46qof26vbzm HOT 3
- Integration tests need randomly assigned ports
- search timestamp handling HOT 3
- BGS: transport compression for non-trivial CAR files
- Missing GraphGetBlocks function HOT 4
- `events.ConsumerPool` observability improvements
- search links in link cards and facets
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 indigo.