標籤:快速鍵 dev ati lan 菜單 ring write tin 查看
Go語言也支援物件導向開發,不過和以往我們所使用的物件導向開發還是有不同,Go語言主張組合方式形成類的概念,在Go語言中,結構起到很大作用,如果用結構組合欄位和方法,那麼單純在原始碼中看,真的是費時費力,尤其看別人寫的代碼,舉例如下:
type rawConnection struct {id DeviceIDname stringreceiver Modelcr *countingReadercw *countingWriterawaiting map[int32]chan asyncResultawaitingMut sync.MutexidxMut sync.Mutex // ensures serialization of Index callsnextID int32nextIDMut sync.Mutexoutbox chan asyncMessageclosed chan struct{}once sync.Oncepool bufferPoolcompression Compression}
這個rawConnection是一個結構,同時它也定義了很多方法,如果僅僅在原始碼裡面查看,真的讓你暈頭轉向,我剛才看rawConnection時候,看了半天,也沒能完整瞭解它,但是,當我開啟Gogland的“Structure”時候,真的不得不表揚Gogland,做得太棒了,立即完整展現了rawConnection,包括它所有的欄位和方法,讓我能夠快速完整瞭解rawConnection!!Gogland預設情況下,“Structure”好像並沒有開啟,如果沒有開啟,我們可以點擊頂部菜單開啟:“View”->"Tools Windows"->"Structure",也可以通過快速鍵“Alt+7”開啟。
通過“Structure”查看rawConnection的整體結構,這個結構的全貌一覽無遺,太棒了!!
Gogland使用 - 非常簡單查看Go語言原始碼全貌!