Note for users in China
Note: if you are behind the Great Firewall of China, you are very likely to encounter problems installing GoClipse: blocked connections, timeouts, or slow downloads. This is because the update site is hosted in Github, which is blocked or has limited access. These alternative instructions should let you perform the installation:
- Download an Eclipse installation which already contains CDT (such as the "Eclipse IDE for C/C++ Developers" package), so CDT doesn't have to be downloaded during installation.
- Download the website from https://github.com/GoClipse/goclipse.github.io/archive/master.zip, unpack the archive and use the
releasesdirectory as a Local repository instead of the Update Site URL. Uncheck the option "Contact all updates sites during installation to find required software" so only the local repository is used.
- Note however: you will likely need to re-download the archive above whenever you want to update GoClipse to a newer version.
由於GFW的原因,不翻牆下載會各種報錯。所以我按照官網教程說明成功完成了安裝。GOROOT和GOPATH可以在安裝完后查看(不能相同)。
不知道是不是仍然是牆的原因,gocode、godef以及guru下載都出現了問題。
CSDN里提供的exe都需要積分,所以我覺得還是直接找github地址下載zip文件。
gocode:
https://github.com/nsf/gocode 下載完后解壓為gocode,然后在根目錄里執行go build得到gocode.exe
guru:
https://github.com/golang/tools 下載完后解壓為$GOPATH$\src\golang.org\x\tools,然后在根目錄里執行go build得到guru.exe
godef:
https://github.com/rogpeppe/godef 下載完后解壓為$GOPATH$\src\github.com\rogpeppe\godef,然后在根目錄里執行go build得到godef.exe
3個編譯好的exe可以在文末鏈接中下載。
eclipse上配置完Go的安裝路徑以及三個exe的位置后,點擊apply即可。
新建完Go項目后主要看bin以及src文件夾,bin中存放的是編譯好之后的exe文件,src存的是源代碼。
不能直接在src下創建go文件,而且必須在src在創建main文件夾,在main文件夾下創建package為main的主文件(如hello.go)
一個package下,只能有一個main方法,不管是在那個文件中,但是只能有一個,這個package是按照文件夾區分的,所以package名應該與文件夾名相同。
項目build之后能夠在bin中看見main.exe,run直接執行。
https://pan.baidu.com/s/1URpwesND1H5R713o5gP-jg
