3000 explained code solutions for 75 technologies


golangHow to get all environment variables


package main
import "os"

func main() {
  for _, env := range os.Environ() {
    print(env, "\n")
  }
}ctrl + c
os.Environ()

returns list of all environment variables

for _, env := range os.Environ()

iterate over all environment variables

import "os"

import os module to work with environment variables