İlk yol:
İkinci Yol:
Kod:
//Go ile ortam değişkenlerini elde etme
package main
import (
"fmt"
"os"
)
func main() {
for _, env := range os.Environ() {
fmt.Println(env)
}
}
İkinci Yol:
Kod:
//Go ile ortam değişkenlerini elde etme
package main
import (
"fmt"
"os"
)
func main() {
uName := os.Getenv("USERNAME")
uDomain := os.Getenv("USERDOMAIN")
processorArchitecture := os.Getenv("PROCESSOR_ARCHITECTURE")
//processorIdentifier := os.Getenv("PROCESSOR_IDENTIFIER")
//processorLevel := os.Getenv("PROCESSOR_LEVEL")
goRoot := os.Getenv("GOROOT")
goPath := os.Getenv("GOPATH")
homePath := os.Getenv("HOMEPATH")
fmt.Println("Username :" + uName)
fmt.Println("Domain :" + uDomain)
fmt.Println("İşlemci Mimarisi :" + processorArchitecture)
fmt.Println("HOMEPATH :" + homePath)
fmt.Println("GOPATH :" + goPath)
fmt.Println("GOROOT :" + goRoot)
}