我是Golang的新手。很抱歉,我仍然对以下两者之间的区别感到困惑: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那么,我们什么时候应该在两者之间使用呢?
1 回答
- 1 回答
- 0 关注
- 303 浏览
添加回答
举报
0/150
提交
取消