Skip to main content

Posts

Showing posts with the label Golang Data type

Primitive data type of Golang

Overview In this blog I am going to talk about the date types and variables in go. and the topics bellow  Declaring and initializing variables   explicit initialization of variables   implicit initialization of variables complex data type list of data type Pointer pointer operator dereferencing operator address of operator Constant Iota and constant expression Declaring and initializing variables there are 2 ways you can declarer and initialize a variable they are explicit initialization variables  implicit initialization variables  Explicit initialization of variables  in this way you have to tell the compiler every thing you need to declare a variable. var i int i = 20 var j int = 3 fmt.Println(i,j) var f float32 = 32.233 fmt.Println(f)  in this way we are explicitly telling what will be the input type for that variable. Implicit initialization of variables  in this way of declaring a variable. we don't have to tell the compiler what type of data it will take on that

List of data types in Golang

  index Description 1 Type: int8 8-bit signed integer 2 Type:  int16 16-bit signed integer 3 Type:  int32 32-bit signed integer 4 Type:  int64 64-bit signed integer 5 Type:  uint8 8-bit unsigned integer 6 Type:  uint16 16-bit unsigned integer 7 Type:  uint32 32-bit unsigned integer 8 Type:  uint64 64-bit unsigned integer 9 Type:  int Both in and uint contain same size, either 32 or 64 bit. 10   Type:  uint Both in and uint contain same size, either 32 or 64 bit. 11 Type:  rune It is a synonym of int32 and also represent Unicode code points. 12 Type:  byte It is a synonym of int8 . 13 Type:  uintptr It is an unsigned integer type. Its width is not defi

Pointer in Golang

  Over view In this blog I am going to talk about pointer and how it works. will talk about  How variable stored in memory ? Pointer Dereferencing How variable stored in memory? to understand pointer one need to know how computer store its  value in memory. By memory i will be refereeing to the RAM. basically computer stores its variable in memory in binary format. and when some one declares a variable it will allocate some bite of memory for that variable. And when variable is initialized it will go to its look up table and search for the first memory address and store data. for int and float it will allocate 4 and char it will allocate 1 byte of memory   suppose I have declared  'a'  as variable which is type int. computer will allocate 4 byte of memory for that and if i declared 'c' as variable with a type char. it will allocate a 1 byte of memory for this. and it will put the first memory address to its lookup table to search for the variable later. then if I ini