go获取环境变量
package main
import (
"fmt"
"os"
)
func main() {
var goos string = os.Getenv("GOPATH")
fmt.Printf("The operating system is: %s\n", goos)
path := os.Getenv("PATH")
fmt.Printf("The PATH is: %s\n", path)
}
输出:
The operating system is: D:\GoPath
The PATH is: C:\windows\SysWOW64;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;D:\mysql5.6\bin;D:\python3.64\anzhuangweizhi;C:\windows\system32;D:\Sublime Text 3 Build installed\Sublime Text 3;D
:\python3.64\anzhuangweizhi\Lib\site-packages\django\bin;C:\Program Files\nodejs\;D:\python2.7\Python2.7_Install;C:\Program Files\Common Files\Intel\WirelessCommon\;E:\Redis\;E:\Git\cmd;C:\Program Files\Docker Toolbox\;C:\Progra
m Files\Oracle\VirtualBox\;D:\RabbitMQ\erlang\erl10.0.1\bin;D:\RabbitMQ\erlang\erl10.0.1\bin;D:\RabbitMQ\rabbitmq_server-3.7.7\sbin;F:\MongoDB\installed_location\bin;D:\Go\bin;D:\GoPath\bin;D:\vscode\Microsoft VS Code\bin;D:\Ope
nSSL\OpenSSL-Win64\bin;C:\Users\Administrator\AppData\Roaming\npm\cnpm;C:\Users\Administrator\AppData\Roaming\npm\supervisor;D:\Anaconda\Installed\condabin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\Wir
elessCommon\;E:\Redis\;C:\Program Files\Docker Toolbox\;C:\Program Files\Oracle\VirtualBox\;D:\prometheus\prometheus-2.33.3.windows-amd64;D:\GoPath\bin;D:\go\bin
写入自己的博客中才能记得长久
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!