Data types in Golang




Hey guys in this post, we will discuss the different datatypes provided by Golang.

  • Integer type
  • Floating type
  • String
  • Boolean
package main

import (
	"fmt"
	"reflect"
)

func main() {
	fmt.Println(reflect.TypeOf(1))
	fmt.Println(reflect.TypeOf(9.5))
	fmt.Println(reflect.TypeOf("Just a String"))
	fmt.Println(reflect.TypeOf(true))
}

Output:

PS C:\workspace\go lang workspace> go run .\Types.go                                                                   int
float64
string
bool

TypeOf() is present in the reflect package and it will return the type of the value.



Bushan Sirgur

Hey guys, I am Bushan Sirgur from Banglore, India. Currently, I am working as an Associate project in an IT company.

Leave a Reply