How to find the type of an object in Go?

前端 未结 14 1133
余生分开走
余生分开走 2020-12-12 09:16

How do I find the type of an object in Go? In Python, I just use typeof to fetch the type of object. Similarly in Go, is there a way to implement the same ?

14条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 09:28

    To be short, please use fmt.Printf("%T", var1) or its other variants in the fmt package.

提交回复
热议问题