OSX Catalina & zsh as my terminal.
I have a command to start a psql connection :
db, err := pgx.Connect(context.Background(), os.Getenv("PSQL_URL"))
But the os.Getenv("PSQL_URL")
is an empty string.
How to make sure go program can read my environment variable ?
In the terminal, if I echo $PSQL_URL
I get the proper postgresql://aod:toto@localhost/dbname
If I export PSQL_URL="postgresql://aod:toto@localhost/dbname"
before running main.go it works fine
I'm looking for a persistent way of doing it.
UPDATE
My mistake was as follow :
Inside ~/.zhsrc
I did set
PSQL_URL="postgresql://aod:toto@localhost
instead of
export PSQL_URL="postgresql://aod:toto@localhost"