1. 程式人生 > 其它 >[轉]GO語言下載、安裝、配置

[轉]GO語言下載、安裝、配置

一、Go語言下載

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

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

二、GO語言安裝

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

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

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

步驟一:雙擊執行安裝程式

步驟二:點選Next,出現License

選擇I accept the terms in the License Agreeement。

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

預設C:\Go\

步驟四:點選Next進行安裝

點選Install按鈕進行安裝

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

點選Finish完成安裝。

三、安裝後目錄說明

Go語言安裝之後,C:\Go目錄下一共有9個目錄與9個檔案,如下圖:

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 企業版):

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

選擇“高階系統設定”

彈出以下對話方塊,選擇“高階”標籤:

點選“環境變數”按鈕,彈出變數設定視窗:

“新建”系統變數:

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

修改系統變數Path,新增C:\Go\bin\

環境變數設定之後,在命令列中輸入go:

按回車鍵:

如檢視version,執行go version

五、總結

Go語言安裝比較簡單,安裝成功之後要配置執行環境變數,與java類似。

隨後將繼續Go語言之旅。

轉自 https://www.cnblogs.com/zsy/p/5215336.html