3000 explained code solutions for 75 technologies


golangHow to set environment variable


package main
import "os"

func main() {
  os.Setenv("MY", "12345")
  print( os.Getenv("MY") )
}ctrl + c
import "os"

import os module to work with environment variables

os.Setenv(

sets given environment variable

MY

name of environment variable to set value of

12345

sample value to set