logo-MindMajix
PostGoLangGoLang
I
Irshad Mohammad

Posted on 23rd June 2024|58 views

0
votes

Golang Typeof

How to find the type of an object in golang?

1 answers
Answers
P
Aryan Sharma

Posted on 23rd June 2024| views

Here is how you do it

Package main

import(

"ftm"

"reflect"

)

func main(){

obj1 = “hello”

obj2 = 20

obj3 = 15.56

ftm.println(reflect.TypeOf(obj1))

ftm.println(reflect.TypeOf(obj2))

ftm.println(reflect.TypeOf(obj3))

}

Output:

string

int

float64 

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number