iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 3
0
Software Development

學習Go系列 第 3

Go day 3 (IDE)

  • 分享至 

  • twitterImage
  •  

下載 IDE

Golang 也有很多 IDE 可以選擇,但這邊使用的是 Visual Studio Code 來開發,先下載下來然後開啟.

https://ithelp.ithome.com.tw/upload/images/20181003/20107343bJ9J6x1rj7.jpg

安裝 Go 的 plugin

接著點左邊第 5 個圖示,然後找 go 並安裝
https://ithelp.ithome.com.tw/upload/images/20181003/20107343cNCPK3Ff70.jpg

open Project

open 要跑的 go project
https://ithelp.ithome.com.tw/upload/images/20181003/20107343A5ADnLaewT.jpg

會有一些錯誤訊息,GOPATH 環境變數沒有對到要執行的 project
https://ithelp.ithome.com.tw/upload/images/20181003/20107343DVpvJsvxmn.jpg

Mac 的話可以下 command + shift + p 可以跑一些 IDE 的指令
https://ithelp.ithome.com.tw/upload/images/20181003/20107343Yv1uIbPJuw.jpg

打開 settings
https://ithelp.ithome.com.tw/upload/images/20181003/20107343luDqxklRwZ.jpg

使用 json 方式打開
https://ithelp.ithome.com.tw/upload/images/20181003/20107343ak1Ufzjg07.jpg

可以在 USER SETTINGS 的地方,寫要覆蓋的參數值
https://ithelp.ithome.com.tw/upload/images/20181003/20107343ov4JQdjLuK.jpg

執行程式

點選左邊第 4 個圖示,然後再點開 launch.json 檔案,加上 Args 所需要的參數,然後就可以點綠色箭頭執行成功
https://ithelp.ithome.com.tw/upload/images/20181003/20107343V4vj1VXME4.jpg

可以在數字前面下中斷點,然後上方會有可以下一步的鍵,方便 debug
https://ithelp.ithome.com.tw/upload/images/20181003/20107343iKOlktbpXI.jpg

IDE Console

在 console 頁籤,就像開一個 terminal 一樣,所以吃的環境變數是 local 的,不是 IDE 的環境變數
https://ithelp.ithome.com.tw/upload/images/20181003/20107343tfWxT8SfTN.jpg

find references

游標移到要找的 function 名稱後按右鍵,或著按 fn + shift + F12
https://ithelp.ithome.com.tw/upload/images/20181003/20107343HHfSp05ghr.jpg


上一篇
Go day 2 (package main)
下一篇
Go day 4 (variables)
系列文
學習Go30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言