2.1關(guān)鍵字和內(nèi)置詞
Go語(yǔ)言關(guān)鍵字:
[if !supportLists]ü? [endif]25個(gè)關(guān)鍵詞;
[if !supportLists]ü? [endif]關(guān)鍵詞不能用于自定義名字;
[if !supportLists]ü? [endif]而且不能命名成變量, 自定義類(lèi)型。
break????? default?????? func????interface?? select
case?????? defer????? ???go??????map???????? struct
chan?????? else????????? goto???? package????switch
const????? fallthrough?? if??????range?????? type
continue?? for??????????import?? return????? var
預(yù)定義字:
[if !supportLists]ü? [endif]37個(gè)以上預(yù)定義詞;
[if !supportLists]ü? [endif]與關(guān)鍵字不同;
[if !supportLists]ü? [endif]可以定義中重新使用它們。
內(nèi)建常量: true false iota nil
內(nèi)建類(lèi)型: int? int8 int16 int32 int64
????????? uint uint8 uint16 uint32 uint64uintptr
????????? float32 float64 complex128 complex64
????????? bool byte rune string error
內(nèi)建函數(shù): make len cap new append copy close delete
????????? complex real imag
????????? panic recover
自定義的變量,函數(shù),類(lèi)型等盡量不用關(guān)鍵字和內(nèi)置詞做名稱。對(duì)于老程序員一般都會(huì)先看看有哪些內(nèi)置關(guān)鍵字等,這里我們就是簡(jiǎn)單列舉,不做過(guò)多介紹。以后會(huì)逐個(gè)涉及的。