[Go] GO语言-获取系统环境变量 →→→→→进入此内容的聊天室

来自 , 2020-09-16, 写在 Go, 查看 170 次.
URL http://www.code666.cn/view/abceedf5
  1. /**
  2.  * Created with IntelliJ IDEA.
  3.  * User: liaojie
  4.  * Date: 12-9-7
  5.  * Time: 下午8:33
  6.  * To change this template use File | Settings | File Templates.
  7.  */
  8. package main
  9.  
  10. import (
  11.         "fmt"
  12.         "os"  //我们要用到os包中的env
  13. )
  14.  
  15.  
  16. func main() {
  17.         //os.Getenv检索环境变量并返回值,如果变量是不存在的,这将是空的。
  18.         HOME:= os.Getenv("HOME")
  19.         fmt.Println(HOME)
  20.         fmt.Printf(os.Getenv("JAVA_HOME"))
  21. }
  22. //go/5607

回复 "GO语言-获取系统环境变量"

这儿你可以回复上面这条便签

captcha