This commit is contained in:
2024-05-04 21:07:59 +05:30
parent 8143c2d08a
commit 47c2d3b2ec
2 changed files with 25 additions and 2 deletions

21
env/env.go vendored Normal file
View File

@@ -0,0 +1,21 @@
package env
import (
"fmt"
"os"
"strings"
)
func Env() {
os.Setenv("GOBYEXAMPLE", "WORKS")
fmt.Println("$GOBYEXAMPLE=", os.Getenv("GOBYEXAMPLE"))
envGoRoot := os.Getenv("GOROOT")
fmt.Println("$GOROOT=", envGoRoot)
fmt.Println()
fmt.Println("All env vars:")
for _, envLine := range os.Environ() {
pair := strings.SplitN(envLine, "=", 2)
fmt.Printf("%s=%s\n", pair[0], pair[1])
}
}