這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
一、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
五、總結