我是Golang的新手。很抱歉,我仍然對以下兩者之間的區(qū)別感到困惑:type <Name> <dataType>和type <Name> = <dataType>這是一個例子:package mainimport "fmt"func main() { var ( strWord Word strText Text ) strWord = "gopher" strText = "golang" fmt.Printf("strWord = %s, Type of Value = %T\n", strWord, strWord) fmt.Printf("strText = %s, Type of Value = %T\n", strText, strText)}type Word stringtype Text = string輸出strWord = gopher, Type of Value = main.WordstrText = golang, Type of Value = string那么,我們什么時候應(yīng)該在兩者之間使用呢?
- 1 回答
- 0 關(guān)注
- 319 瀏覽
添加回答
舉報
0/150
提交
取消