Golang os.Environ() and Getenv() functions examples
package os
Golang os.Environ() and Getenv() functions usage examples
Example 1:
Get all environment variables
package main
import (
"fmt"
"os"
)
func main() {
env := os.Environ()
//fmt.Println(env)
for _, v := range env {
fmt.Printf(" %v \n", v)
}
}
Example 2 :
Get one environment variable
Home := os.Getenv("HOME")
Reference :
Advertisement
Something interesting
Tutorials
+5.7k Golang : Error handling methods
+13.8k Golang : unknown escape sequence error
+9.3k Golang : Timeout example
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+5.4k Golang : Get S3 or CloudFront object or file information
+16.8k Golang : Get own process identifier
+10.1k Golang : Edge detection with Sobel method
+15.6k Golang : Get checkbox or extract multipart form data value example
+20.8k Golang : Underscore or snake_case to camel case example
+5.2k Golang : Convert lines of string into list for delete and insert operation
+7.9k Golang Hello World Example
+5.5k Golang : Stop goroutine without channel