Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 408 Bytes

golang中type类型定义.md

File metadata and controls

27 lines (19 loc) · 408 Bytes

golang中type类型定义

在golang中,type的使用有两种方式:

  • 类型定义
type Student struct {
    name string
    age int
}
  • 类型等价定义
var cnt I = 123
fmt.Printf("%d", cnt)
  • 类型别名
type strMap2Any = map[string]interface {}

相当于别名alias,这样在json操作中,使用别名就能让代码看起来更加简洁。