How to find the type of an object in Go?

前端 未结 14 1156
余生分开走
余生分开走 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:38

    You can just use the fmt package fmt.Printf() method, more information: https://golang.org/pkg/fmt/

    example: https://play.golang.org/p/aJG5MOxjBJD

提交回复
热议问题