▲ 1 ▼ Using Golang stdlib interfaces eltonminetto.dev posted by Elton Minetto 932 days ago ▲ shoggothe 921 days ago ▼ // try to avoid this pattern What to avoid, why to avoid? No explanation at all! In the end it's perfectly fine to ask for environment variables. Just don't do it every time. I guess @jot thinks os.Getenv is called all the time here and she/he could be right. Or @jot is talking about something completely different, nobody knows. Saying to avoid something without explanation isn't very helpful. All I could do was guessing. Contributing ▲ jot 929 days ago ▼ Very nice. stdlib, one of those strong features Go is built upon. But please do not use these kind of snippets in code: if os.Getenv('ENV') == "prod" // try to avoid this pattern Even in examples. People tend to use what they see, especially in well written articles such as yours. Contributing Register to comment or vote on this story
// try to avoid this pattern
What to avoid, why to avoid? No explanation at all! In the end it's perfectly fine to ask for environment variables. Just don't do it every time.
I guess @jot thinks os.Getenv is called all the time here and she/he could be right.
Or @jot is talking about something completely different, nobody knows.
Saying to avoid something without explanation isn't very helpful. All I could do was guessing.
Very nice. stdlib, one of those strong features Go is built upon. But please do not use these kind of snippets in code:
if os.Getenv('ENV') == "prod" // try to avoid this pattern
Even in examples. People tend to use what they see, especially in well written articles such as yours.