How to find the type of an object in Go?

前端 未结 14 1134
余生分开走
余生分开走 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条回答
  •  Happy的楠姐
    2020-12-12 09:28

    Best way is using reflection concept in Google.
    reflect.TypeOf gives type along with the package name
    reflect.TypeOf().Kind() gives underlining type

提交回复
热议问题