Standard Library
dotenv
Read configuration values from a .env file or the surrounding process environment.
Import:
import "dotenv";envvar
Look up a value by name. If a .env file is present in the working directory, its keys are loaded automatically.
string key = envvar("AI_API_KEY");
string url = envvar("AI_URL");Example .env
AI_URL=https://api.openai.com/v1/chat/completions
AI_MODEL=gpt-4
AI_API_KEY=sk-...Never commit your .env file. Add it to .gitignore so secrets stay on the machines that need them.