philipbohun.com

Glojure by Example: Environment Variables

os.Setenv sets a variable for this process and its children. os.Getenv reads one. A missing variable reads as an empty string.

(os.Setenv "GLJ_EXAMPLE" "glojure")
(println (os.Getenv "GLJ_EXAMPLE"))
(println (str "missing=[" (os.Getenv "GLJ_EXAMPLE_MISSING") "]"))

The value set here is visible to the rest of the process.

$ glj environment-variables.glj
glojure
missing=[]

Next example: Logging.