How to get an environment variable in Go?

In Go lang, how to get an environment variable?

To get an environment variable (e.g. “VAR”) in GO:

import "os"
import "fmt"

fmt.Println("VAR:", os.Getenv("VAR"))
Answered by zma.

Leave a Reply

Your email address will not be published. Required fields are marked *