My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)


Tuesday, September 20, 2022

Fetching Environment Variable with Existence Check - Golang

Fetching a specific environment var from execution environment (where Go program is running) is little trick as Go provide 2 methods/function for that. Choose the function based on the requirement.  

  This function will return value if Env var exists or return empty string if not. So it is difficult to gather if Env var value is empty or Env var is not exists. 

  To overcome above problem, this function will check if Env var existence and return either value or the error. 

Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group

No comments:

Post a Comment


The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.