gO語言的安裝和環境變量的配置


一、Go語言下載

go語言官方下載地址:https://golang.org/dl/

QQ圖片20160224204006

找到適合你系統的版本下載,本人下載的是windows版本。也可以下載Source自己更深層次研究go語言。

二、GO語言安裝

下載完成之后,雙擊go1.6.windows-amd64.msi進行安裝。

如果安裝過程出現以下提示:

QQ圖片20160224204435

以管理員的身份運行cmd,找到go1.6.windows-amd64.msi所在的目錄,並輸入msiexec /i go1.6.windows-amd64.msi如下圖(放在D盤根目錄):

QQ圖片20160224205030

步驟一:雙擊運行安裝程序

QQ圖片20160224205126

步驟二:點擊Next,出現License

QQ圖片20160224205243

選擇I accept the terms in the License Agreeement。

步驟三:點擊Next,選擇安裝路徑

image

默認C:\Go\

步驟四:點擊Next進行安裝

image

點擊Install按鈕進行安裝

image

image

步驟五:耐心等待,直到以下界面

image

點擊Finish完成安裝。

三、安裝后目錄說明

Go語言安裝之后,C:\Go目錄下一共有9個目錄與9個文件,如下圖:

image

api — 目錄,包含所有API列表,方便IDE使用

bin— 目錄,存放編譯后的可執行文件

blog— 目錄,

doc— 目錄,幫助文檔

lib— 目錄,

misc— 目錄,

pkg— 目錄,存放編譯后的包文件。pkg中的文件是Go編譯生成的

src— 目錄,存放項目源文件

注:一般,bin和pkg目錄可以不創建,go命令會自動創建(如 go install),只需要創建src目錄即可。

Authors— 文件,作者列表,用記事本打開

CONTRIBUTING.md— 文件,

CONTRIBUTORS— 文件,

favicon.ico— 文件,

LICENSE— 文件,license,用記事本打開

PATENTS— 文件,

README.md— 文件,

robots.txt— 文件,使用robots.txt阻止對網址的訪問,詳情查看https://support.google.com/webmasters/answer/6062608?hl=zh-Hans

VERSION— 文件,版本信息,用記事本打開

四、設置GO環境變量

官方文檔:

If you chose a directory other than c:\Go, you must set the GOROOT environment variable to your chosen path.

Add the bin subdirectory of your Go root (for example, c:\Go\bin) to your PATH environment variable.

Setting environment variables under Windows

Under Windows, you may set environment variables through the "Environment Variables" button on the "Advanced" tab of the "System" control panel. Some versions of Windows provide this control panel through the "Advanced System Settings" option inside the "System" control panel.

具體設置步驟如下(windows 10 企業版):

找到:我的電腦,右鍵,打開“屬性”

image

選擇“高級系統設置”

image

彈出以下對話框,選擇“高級”標簽:

image

點擊“環境變量”按鈕,彈出變量設置窗口:

image

“新建”系統變量:

image

設置變量名GOROOT,變量值C:\Go\(安裝目錄)

修改系統變量Path,添加C:\Go\bin\

image

環境變量設置之后,在命令行中輸入go:

image

image

按回車鍵:

image

如查看version,運行go version

image

五、總結


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM